Merge pull request #214 from multica-ai/codex/chat-context-window-indicator

feat(chat): add context window usage indicator
This commit is contained in:
Jiayuan Zhang 2026-02-17 00:55:09 +08:00 committed by GitHub
commit fc8a813120
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 284 additions and 23 deletions

View file

@ -553,6 +553,20 @@ export class AsyncAgent {
return this.agent.getProviderInfo();
}
/**
* Get persisted session metadata.
*/
getSessionMeta(): import("./session/types.js").SessionMeta | undefined {
return this.agent.getSessionMeta();
}
/**
* Get effective context window token limit for this session.
*/
getContextWindowTokens(): number {
return this.agent.getContextWindowTokens();
}
/**
* Switch to a different provider and/or model.
* This updates the agent's model without recreating the session.

View file

@ -15,6 +15,7 @@ import {
getDefaultModel,
} from "./providers/index.js";
import { SessionManager } from "./session/session-manager.js";
import type { SessionMeta } from "./session/types.js";
import { ProfileManager } from "./profile/index.js";
import { SkillManager } from "./skills/index.js";
import { credentialManager, getCredentialsPath } from "./credentials.js";
@ -1199,6 +1200,20 @@ export class Agent {
};
}
/**
* Get persisted session metadata.
*/
getSessionMeta(): SessionMeta | undefined {
return this.session.getMeta();
}
/**
* Get effective context window token limit for this session.
*/
getContextWindowTokens(): number {
return this.session.getMeta()?.contextWindowTokens ?? this.session.getContextWindowTokens();
}
/**
* Switch to a different provider and/or model.
* This updates the agent's model without recreating the session.