Skip to content
Merged
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 package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "billion-context-pi",
"version": "0.1.62",
"version": "0.1.63",
"description": "One billion, not one million. Model-driven context management for the Pi coding agent.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { makeStatusTool } from "./status-tool.js";
import { makeDelegateTool, makeDelegateWaitTool, makeDelegateCancelTool, runningRunsSnapshot, resetDelegateUsage, setDelegateDisplayUsage, setDelegatePolicy, setDelegateDefaults, setDelegateNotifyIfRead, markDelegateResultRead, markDelegateRunReadByCommand } from "./delegate-tool.js";
import { makeCommands } from "./commands.js";
import { coreOutToAgentMessages, extractText } from "./messages.js";
import { dropCompressReasoning } from "./reasoning-drop.js";
import { countThinkingChars, dropCompressReasoning } from "./reasoning-drop.js";
import { buildAcpSystemPrompt, ACP_DELEGATE_PROMPT } from "./system-prompt.js";
import { delegateStatusWidget } from "./fleet-widget.js";
import { openFleetInspector } from "./fleet-inspector.js";
Expand Down Expand Up @@ -412,7 +412,8 @@ function wireContextTransform(pi: ExtensionAPI, runtime: AcpRuntime, standDownIf
const reasoningDrop = runtime.reasoningDropFor(ctx);
const droppedThinking = dropCompressReasoning(rebuilt, reasoningDrop);
if (droppedThinking !== rebuilt) {
debug.event("reasoning-drop", { sid, dropped: droppedThinking.length, drop: reasoningDrop.drop, threshold: reasoningDrop.threshold });
const droppedChars = countThinkingChars(rebuilt) - countThinkingChars(droppedThinking);
debug.event("reasoning-drop", { sid, droppedChars, drop: reasoningDrop.drop, threshold: reasoningDrop.threshold });
}
rebuilt = droppedThinking;
const debugOn = debug.enabled;
Expand Down
4 changes: 4 additions & 0 deletions src/reasoning-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ function reasoningLength(content: unknown): number {
return content.reduce((n, p) => (isThinking(p) ? n + p.thinking.length : n), 0);
}

export function countThinkingChars(messages: AgentMessage[]): number {
return messages.reduce((n, m) => n + reasoningLength((m as { content?: unknown }).content), 0);
}

/** Request-time pass aligned with opencode-acp #377: remove `thinking` parts
* from a message only when ALL gates hold —
* 1. closed round [#348]: EVERY `compress` toolCall in the message has its
Expand Down
Loading