mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 10:02:23 +00:00
mom: add context usage to thread summary, update docs
- Usage summary now shows context tokens vs model context window - Updated CHANGELOG.md with all recent changes - Updated README.md with new file structure (log.jsonl/context.jsonl)
This commit is contained in:
parent
99fe4802ef
commit
71b776e290
4 changed files with 87 additions and 30 deletions
|
|
@ -617,9 +617,24 @@ function createRunner(sandboxConfig: SandboxConfig, channelId: string, channelDi
|
|||
}
|
||||
}
|
||||
|
||||
// Log usage summary
|
||||
// Log usage summary with context info
|
||||
if (runState.totalUsage.cost.total > 0) {
|
||||
const summary = log.logUsageSummary(runState.logCtx!, runState.totalUsage);
|
||||
// Get last non-aborted assistant message for context calculation
|
||||
const messages = session.messages;
|
||||
const lastAssistantMessage = messages
|
||||
.slice()
|
||||
.reverse()
|
||||
.find((m) => m.role === "assistant" && (m as any).stopReason !== "aborted") as any;
|
||||
|
||||
const contextTokens = lastAssistantMessage
|
||||
? lastAssistantMessage.usage.input +
|
||||
lastAssistantMessage.usage.output +
|
||||
lastAssistantMessage.usage.cacheRead +
|
||||
lastAssistantMessage.usage.cacheWrite
|
||||
: 0;
|
||||
const contextWindow = model.contextWindow || 200000;
|
||||
|
||||
const summary = log.logUsageSummary(runState.logCtx!, runState.totalUsage, contextTokens, contextWindow);
|
||||
runState.queue.enqueue(() => ctx.respondInThread(summary), "usage summary");
|
||||
await queueChain;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue