Account for full context tokens in compression (#908)

* Account for full context tokens in compression

* Fix group chat final context updates

---------

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
ekko
2026-05-21 19:40:52 +08:00
committed by GitHub
co-authored by Codex
parent b2ec321990
commit 39ead94352
16 changed files with 730 additions and 35 deletions
@@ -90,6 +90,14 @@ export interface AgentBridgeRunResult extends AgentBridgeResponse {
error?: string | null
}
export interface AgentBridgeContextEstimate extends AgentBridgeResponse {
session_id: string
token_count?: number | null
message_count: number
tool_count: number
system_prompt_chars: number
}
export interface AgentBridgeCommandResult extends AgentBridgeResponse {
session_id: string
command: string
@@ -372,6 +380,24 @@ export class AgentBridgeClient {
})
}
contextEstimate(
sessionId: string,
messages: unknown[],
instructions?: string,
profile?: string,
options: Pick<AgentBridgeChatOptions, 'model' | 'provider'> = {},
): Promise<AgentBridgeContextEstimate> {
return this.request<AgentBridgeContextEstimate>({
action: 'context_estimate',
session_id: sessionId,
messages,
...(instructions ? { instructions } : {}),
...(profile ? { profile } : {}),
...(options.model ? { model: options.model } : {}),
...(options.provider ? { provider: options.provider } : {}),
})
}
command(sessionId: string, command: string): Promise<AgentBridgeCommandResult> {
return this.request<AgentBridgeCommandResult>({
action: 'command',