Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#

# Add homebrew to PATH for non-interactive shells
export PATH="/Users/s/Library/pnpm:/opt/homebrew/bin:$PATH"
export PATH="/opt/homebrew/bin:$HOME/.local/bin:$PATH"

echo "🔍 Running Gitleaks to check for secrets..."

# Check if gitleaks is installed
if ! command -v gitleaks &> /dev/null; then
if ! command -v gitleaks > /dev/null 2>&1; then
echo ""
echo "❌ ERROR: Gitleaks is not installed!"
echo ""
Expand Down
1 change: 1 addition & 0 deletions packages/copilot-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-tooltip": "^1.2.8",
"@streamdown/code": "^1.0.1",
"@streamdown/math": "^1.0.2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.0",
"html-to-image": "^1.11.13",
Expand Down
4 changes: 3 additions & 1 deletion packages/copilot-sdk/src/chat/AbstractAgentLoop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,10 @@ export class AbstractAgentLoop implements AgentLoopActions {
}

// Create new abort controller for this batch
// Do NOT reset _isCancelled here — if stop() was called between the
// iteration check above and this line, we must not wipe that signal.
// _isCancelled is only reset in resetIterations() (called by sendMessage).
this.abortController = new AbortController();
this._isCancelled = false;
this._isProcessing = true;

this.setIteration(this._iteration + 1);
Expand Down
13 changes: 13 additions & 0 deletions packages/copilot-sdk/src/chat/ChatWithTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export interface ChatWithToolsConfig {
yourgptConfig?: YourGPTConfig;
/** Enable debug logging */
debug?: boolean;
/**
* Controls how multi-turn agent responses appear in the UI.
* - `'multi-step'` (default) — one bubble per server agent iteration.
* - `'single-turn'` — all iterations collapsed into one bubble per user turn.
*/
streamMode?: "multi-step" | "single-turn";
/** Initial messages */
initialMessages?: UIMessage[];
/** Initial tools to register */
Expand Down Expand Up @@ -152,6 +158,7 @@ export class ChatWithTools {
onCreateSession: config.onCreateSession,
yourgptConfig: config.yourgptConfig,
debug: config.debug,
streamMode: config.streamMode,
initialMessages: config.initialMessages,
state: config.state,
transport: config.transport,
Expand Down Expand Up @@ -281,6 +288,12 @@ export class ChatWithTools {
const results = await this.agentLoop.executeToolCalls(toolCallInfos);
this.debug("Tool results:", results);

// If stop() was called while tools were executing, don't restart the loop
if (this.agentLoop.isCancelled) {
this.debug("Skipping continueWithToolResults — loop was cancelled");
return;
}

// Continue chat with tool results
if (results.length > 0) {
const toolResults = results.map((r) => ({
Expand Down
Loading