Repository navigation
feat(cli): --env overlay for usage and orient probes - #656
creativebastard wants to merge 1 commit into
Conversation
Hosts running several agents under one runtime with different accounts (isolated KIMI_CODE_HOME per account) could not point the no-code usage surfaces at any account but the default home's: one capped account was reported rate_limited for the whole runtime and every agent stalled. Thread a repeatable --env KEY=VALUE option through 'oar usage' and 'oar orient' into the session env overlay the library already plumbs into the account usage readers, so a host can probe per account. The usage command moves into its own module, mirroring orient, so the command is parser-testable. Closes botiverse#655
|
Thanks for this and for the diagnosis in #655. Before reviewing the flag, we are checking whether it is needed: from reading the code,
|
|
Full-suite verification (local, 2026-11-06): |
|
Closed by Cindy, an agent of Reason: Closing, with thanks for the diagnosis in #655. The problem is real but the flag is not needed: the CLI already inherits its environment, and a run with real Kimi 2.4.1 and two isolated accounts confirmed that
|
…658) <!-- stamp:review:v1 --> <sup><img src="https://cdn.slock.ai/avatars/6aabf32c-20bc-4cba-b55a-2aa72b60999b/8ba4452ceb890f1930886ef4286fdb99.webp" width="16" height="16" align="absmiddle" alt=""> <b>Otter</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_a4567485b0e7894036f51db66c7a17e4"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup> --- <!-- /stamp:review:v1 --> The existing CLI already selects another Kimi account through its inherited process environment. Document this for usage and account-depth orientation, including PowerShell, and clarify that a rate-limit verdict applies to the selected account/configuration rather than every account on that runtime. No environment flag or product behavior changes. A real Kimi 2.4.1 regression logs into two isolated synthetic accounts against a local server. Switching A → B → A changes both usage identity/quota and orientation JSON/table consistently; no login occurs during reads. The test joins the existing native login CI suite. The reproducible built-CLI probe and selected results are under `experiments/orientation/kimi-accounts.md`. Validation: full check (3,585 unit tests and 18 mock cases), build, and five native Kimi login/account cases passed on Linux. PowerShell syntax is documented from Microsoft; Windows execution remains for CI. No real account or inference was used. Related: #655, #656, #657. Co-authored-by: Otter <[email protected]>
Problem
Hosts that run several agents under one runtime with different accounts (the supported isolated-home pattern — each account in its own
KIMI_CODE_HOME) had no way to point the no-code account-usage surfaces at anything but the default home's credential slot:oar usageaccepted no environment input at all.oar orientaccepted none either.kimiAccountUsageresolves its token fromKIMI_CODE_HOME, and the library already plumbs a session env overlay throughorient({ env })— but with no way to express that overlay from the CLI, the probe always reads~/.kimi-code/credentials/kimi-code.json. Whichever account lives there decidesrateLimitedfor the whole runtime viausability(), so one capped account stalls every agent on the runtime — including agents whose own account still has quota. (Full diagnosis in #655.)Change
packages/cli/src/env-option.ts(new): parse repeatable--env KEY=VALUEintoSessionOptions["env"](later wins;KEY=sets an empty string), plus a commander collector that appends instead of clobbering.packages/cli/src/usage.ts(new): theusagecommand factored out of the composition root into a standalone, parser-testable command — mirroring howorientis built — now accepting--envand passing the overlay toruntime.accountUsage().packages/cli/src/orient.ts:orientaccepts--envand threads it intoorient().tests/cli-usage.test.tscovers the overlay reaching the reader, the no-flag default, malformed-flag rejection, and the parser table;tests/cli-orient.test.tsgains an env-threading test through the realorient().Usage
# Probe the account an agent actually runs under, not the default home: oar usage kimi --env KIMI_CODE_HOME=/home/agent-a oar orient --depth account --env KIMI_CODE_HOME=/home/agent-aHosts keying stall decisions on usage should key per
(runtime id, account identity from the snapshot)rather than per runtime id alone; the CLI gap was what made that impossible without re-implementing the readers.Verification
pnpm run typecheck— cleanpnpm run lint— 0 warnings, 0 errorspnpm run testsuite: running at PR open; will confirm before mergeCloses #655