Repository navigation
Conversation
## summary - Record provider-neutral token and KV-cache metrics (`promptTokens`, `completionTokens`, `totalTokens`, `cachedPromptTokens`, `cacheMissPromptTokens`, `reasoningTokens`, and `cacheHitRate`) in `ModelGateway` for SSE and bounded 2xx JSON responses, emitting an idempotent `turn.usage` summary on turn close without altering stream framing. - Extend `project.get`, `read_project`, and `opendirector project show` with `view="summary"` and `itemIds` scoping to cut multi-node context bytes while preserving authoritative object identities and revisions. - Add side-effect-free `generation.precheck` across HTTP `/queries`, Agent `query`, and `opendirector generation precheck`, sharing backend generation validation, lock and queue checks, duration/byte estimates, confirmation hints, and `Accept-Language` error localization. - Document the CLI options in Chinese and English and cover transport, HTTP, Agent gateway, and CLI equivalence in automated tests. ## validation - `python scripts/generate_contracts.py --check` - `lint-imports` - `pytest tests/test_model_gateway.py tests/test_agent_observability_and_queries.py tests/test_agent_metadata.py tests/test_agent_gateway.py tests/test_cli.py -q` - `npm run check:i18n` Fixes: ThinkFlowLab#337 Refs: ThinkFlowLab#188, ThinkFlowLab#261
github-actions
Bot
requested review from
FayeSpica,
Probiotics5333,
allendyu and
wuzhf9
November 15, 2026 09:25
## summary - Merge split SSE usage chunks and parse `input_tokens_details`, `output_tokens_details`, `cache_read_input_tokens`, and `cache_creation_input_tokens` in `ModelGateway` so multi-chunk streams and cache read/write dialects preserve prompt and cache metrics. - Include sanitized `models` in `project.get` `view="summary"` to match `read_project` and the `ThinkFlowLab#337` compact summary contract across HTTP and CLI queries. - Align `generation.precheck` with `CreationGeneration.prepare` for tool-only protocols, MiniMax model allowlists, image/video output sizes and resolutions, continuation aspect ratios, default durations, and reference-music score helpers. - Add regression tests for split SSE usage chunks, summary `models`, and `generation.precheck` vs `CreationGeneration.prepare` rejection parity. ## validation - `.venv/bin/python3 scripts/generate_contracts.py --check` - `PYTHONPATH=packages/core/src:apps/api/src .venv/bin/lint-imports` - `PYTHONPATH=packages/core/src:apps/api/src .venv/bin/python3 -m pytest tests/test_model_gateway.py tests/test_agent_observability_and_queries.py tests/test_creation_contracts.py tests/test_agent_metadata.py tests/test_agent_gateway.py tests/test_cli.py -q` - `npm run check:i18n` Refs: ThinkFlowLab#337
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
promptTokens,completionTokens,totalTokens,cachedPromptTokens,cacheMissPromptTokens,reasoningTokens, andcacheHitRate) inModelGatewayacross SSE streams and bounded 2xx JSON responses, emitting an idempotentturn.usagesummary on turn close without modifying stream framing or response bytes.project.get,read_project, andopendirector project showwithview="summary"anditemIdsscoping to bound multi-node Agent context bytes while preserving authoritative object identities and revisions.generation.precheckacross HTTP/queries, Agentquery, andopendirector generation precheck, sharing backend generation validation, lock and queue checks, duration/byte estimates, confirmation hints, andAccept-Languageerror localization.src/contracts/creation.schema.jsonandsrc/contracts/generated.ts, and document the new CLI flags in both Chinese and English indocs/guides/cli.md.Linked issue
Fixes #NorRefs #Nis included, or no issue appliesFixes #337
Refs #188, #261
Labels
Suggested taxonomy labels (external fork contributor; automated classifier / maintainer can apply):
type:feat,area:agent,area:canvas,area:docs.Test plan
python scripts/generate_contracts.py --check(verified)lint-imports(134 files analyzed, 4 contracts kept, 0 broken)pytest tests/test_model_gateway.py tests/test_agent_observability_and_queries.py tests/test_creation_contracts.py tests/test_agent_metadata.py tests/test_agent_gateway.py tests/test_cli.py -q(passed)npm run check:i18n(3014 keys, 0 problems)origin/mainOPENDIRECTOR_REAL_CLI=1),npm run build(node_modulesTypeScript compiler not installed in the local container), and browser lanes.Evidence that it works
TestClient,ToolGateway,ModelGatewayloopback SSE/JSON streams, andCliRunnerJSON receipts.Provider verification
No live commercial or GPU provider calls were made. SSE and JSON usage normalization (
prompt_tokens_details.cached_tokens,prompt_cache_hit_tokens,cache_read_input_tokens, andcompletion_tokens_details.reasoning_tokens) andgeneration.precheckvalidation were verified using deterministic local HTTP/SSE transports and real local project storage.Bilingual UI
Accept-Languagelocalization (zh-CNanden-US) is wired forgeneration.precheckissues on/queries,docs/guides/cli.mdis updated in both Chinese and English, andnpm run check:i18npassed with zero issues.