Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): report Grok context window usage #11284

Closednounder(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/11284/headopened View on GitHub

Showing 7 changed files with 75 additions and 0 deletions (loading 4).

x
0 of 7 viewed, 7 left
11 additions and 0 deletionsapps/server/scripts/acp-mock-agent.tsModified
View file
@@ -618,6 +618,17 @@
const requestedSessionId = String(request.sessionId ?? sessionId);
promptCount += 1;
​
+ if (process.env.T3_ACP_EMIT_USAGE === "1") {
+ yield* agent.client.sessionUpdate({
+ sessionId: requestedSessionId,
+ update: {
+ sessionUpdate: "usage_update",
+ used: promptCount === 1 ? 42_000 : 0,
+ size: promptCount === 1 ? 128_000 : 256_000,
+ },
+ });
+ }
+​
if (completeFirstPromptOnCancel && promptCount === 1) {
yield* agent.client.sessionUpdate({
sessionId: requestedSessionId,
46 additions and 0 deletionsapps/server/src/provider/Layers/GrokAdapter.test.tsModified
View file
@@ -339,6 +339,52 @@
}),
​
+ it.effect("reports ACP context usage and replaces it with zero on a later turn", () =>
+ Effect.gen(function* () {
+ const threadId = ThreadId.make("grok-context-usage");
+ const wrapperPath = yield* Effect.promise(() =>