Skip to content

[bugfix] agent: distinguish wait mode and zero-duration queries in waitOutcome and tool counts (#449) - #701

Open
Redivesue wants to merge 1 commit into
ThinkFlowLab:mainfrom
Redivesue:fix/449-wait-outcome-modes
Open

Redivesue wants to merge 1 commit into
ThinkFlowLab:mainfrom
Redivesue:fix/449-wait-outcome-modes

Conversation

@Redivesue

@Redivesue Redivesue commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up fix to #681 addressing the waitOutcome and execution-record count edge cases raised in review (#681#pullrequestreview-6192347681):

  1. Record requested wait mode, duration, and satisfaction in waitOutcome (gateway.py)

    • wait_outcome() now records waitSeconds, until ("all" | "any" for job.status), and satisfied alongside settled and statuses/status.
    • satisfied matches CreationCanvas.wait_jobs() / wait_item_status() semantics:
      • waitSeconds <= 0 (immediate status query): satisfied = True (never treated as an expired wait window).
      • until == "any" with at least one terminal job (succeeded/failed/cancelled/interrupted): satisfied = True even when other jobs are still running (settled = False).
      • until == "all" with waitSeconds > 0 and unfinished jobs: satisfied = False, settled = False.
    • Existing settled semantics stay unchanged for backward compatibility with saved records and scripts/trace_job_queries.py.
  2. Count completed calls by tool return status and separate expired waits from still-running observations (assistantActivity.ts, AssistantReply.tsx, chat.ts, i18n, docs/architecture/agent-runtime.md)

    • toolCounts() counts every status === "complete" call in {done}/{total} complete / {done}/{total} 已完成 rather than subtracting successful until="any", waitSeconds=0, or timed-out until="all" calls.
    • Completed calls with waitOutcome.settled === false are split into two mutually exclusive display states:
      • unsettled (satisfied === false, expired wait window): row badge Not finished / 未结束 (is-unsettled), summary {count} wait not finished / {count} waits not finished ({count} 次等待未结束).
      • jobsRunning (satisfied === true, e.g., until="any" satisfied or waitSeconds=0 status query while jobs are still running): row badge Jobs running / 仍有任务运行 (is-jobs-running), summary {count} with jobs still running ({count} 次返回时仍有任务运行).
    • Legacy #681 records without satisfied infer jobsRunning when arguments.waitSeconds === 0 or arguments.until === "any" with a terminal status present, and older records without waitOutcome remain Complete / 已完成.
  3. Add all three requested regressions

    • until="any" satisfied (1 succeeded + 1 running), until="all" wait window expired, and waitSeconds=0 zero-duration query across unit & POSIX transport tests (tests/test_wait_outcome.py), SSE/persistence reload tests (tests/test_assistant_conversations.py), frontend state tests (tests/assistantActivity.test.ts), and bilingual Playwright browser test (tests/browser/assistant_wait_outcome.mjs).

Linked issue

Refs #449.

  • Fixes #N or Refs #N is included, or no issue applies

Labels

Proposed: type:bug, area:agent, area:canvas, area:i18n, area:docs (fork PR without label write permission).

  • Labels applied

Test plan

  • Local (on rebased tip 92c468f4617d867ce1b8562fb7d61f93e70f058d over base 322f98c317322c1ac12541093719c890507b51b0; byte-for-byte identical patch to 4b48bf23 over 4cd524ce with zero overlapping files against #700):
    • Re-verified directly on 92c468f4: pytest tests/test_wait_outcome.py tests/test_assistant_conversations.py -k "wait_outcome or transport_records" (8 passed), node --test tests/assistantActivity.test.ts (7 passed), npm run check:i18n (3,866 keys, 0 problem(s)), npm run check:browser-manifest (OK, 113 entries), npm run check:browser-locale (102 page(s), 0 problem(s)).
    • Full targeted checks on identical patch 4b48bf23: pytest tests/test_wait_outcome.py tests/test_agent_gateway.py tests/test_assistant_conversations.py tests/test_trace_job_queries.py (79 passed, 0 failed), scripts/generate_contracts.py --check, lint-imports (4 kept, 0 broken), npx tsc --noEmit, npm test (1,118 passed, 0 failed), node --check tests/browser/assistant_wait_outcome.mjs, npm run build (3.95 s), and live in-app browser verification against an isolated real OpenDirector API + Vite dev server (Wait Mode Semantics Demo, verified en-US collapsed & expanded, full page.reload persistence, and live header language toggle to zh-CN with zero cross-language leakage).
  • Left to CI: hosted Release checks workflow (full repo pytest tests, Playwright browser lanes including tests/browser/assistant_wait_outcome.mjs, frontend checks), CodeQL, and DSH plugin checks on exact tip 92c468f4617d867ce1b8562fb7d61f93e70f058d.
  • Independent pre-review: 93/100, 0 blocking findings. Reviewed base 322f98c317322c1ac12541093719c890507b51b0, head 92c468f4617d867ce1b8562fb7d61f93e70f058d. Material validation gaps: hosted Release checks / CodeQL / DSH and full repo pytest have not yet run on 92c468f4, full 79-test pytest / build / in-app browser walkthrough ran on the byte-for-byte identical patch 4b48bf23 prior to clean rebase onto 322f98c3 (zero overlapping files), playwright-core is not installed locally so tests/browser/assistant_wait_outcome.mjs is left to CI Playwright lanes, and no live external model provider calls were made.

Evidence that it works

In-app OpenDirector walkthrough video & bilingual screenshots (4b48bf23)

Captured directly in the running OpenDirector application (create_app isolated backend + Vite frontend, project Wait Mode Semantics Demo) with a persisted 5-call turn written through agent.py:

  1. until="all", waitSeconds=60, 2 running -> Not finished / 未结束 (is-unsettled)
  2. until="any", waitSeconds=60, 1 succeeded + 1 running -> Jobs running / 仍有任务运行 (is-jobs-running)
  3. waitSeconds=0, 1 running -> Jobs running / 仍有任务运行 (is-jobs-running)
  4. until="all", waitSeconds=60, 2 succeeded -> Complete / 已完成 (is-complete)
  5. Legacy project show (no waitOutcome) -> Complete / 已完成 (is-complete)

Before this fix, the same 5-call turn displayed as 2/5 complete · 3 returned before jobs finished / 2/5 已完成 · 3 次返回时任务未结束, with rows 2 (until="any" satisfied) and 3 (waitSeconds=0 query) both marked Not finished / 未结束. With this fix, all 5 calls count as completed tool calls (5/5 complete / 5/5 已完成), with summary 5/5 complete · 1 wait not finished · 2 with jobs still running / 5/5 已完成 · 1 次等待未结束 · 2 次返回时仍有任务运行.

Locale In-app OpenDirector screenshot (Wait Mode Semantics Demo, right-hand AI Assistant expanded)
en-US en-US wait mode semantics
zh-CN zh-CN wait mode semantics
  • Applicable evidence attached and any visual N/A explained

Provider verification

No real-provider calls were made. All tests exercise local ToolGateway, POSIX CLI transport, in-process ASGI conversation persistence, and frontend state/rendering fixtures.

  • Real-provider calls are described honestly, or none were made

Bilingual UI

Both zh-CN and en-US entries are updated together (assistant.reply.status.jobsRunning, assistant.reply.jobsRunningCount, and pluralized assistant.reply.unsettledCount), tests/browser/assistant_wait_outcome.mjs and the live in-app walkthrough verify zero cross-language leakage, and npm run check:i18n passes with 0 problems.

  • Both locales are updated, or no user-facing copy changed

Quick local verification case for reviewers

On this PR branch (gh pr checkout 701):

# 1. Verify all 3 regressions (any-satisfied, all-expired, zero-duration) in backend & SSE persistence
pytest tests/test_wait_outcome.py tests/test_assistant_conversations.py -k "wait_outcome or transport_records" -vv

# 2. Verify frontend counts, display states, i18n, and architecture boundaries
node --test tests/assistantActivity.test.ts
npm run check:i18n
npm run check:browser-manifest
npm run check:browser-locale
python scripts/generate_contracts.py --check
lint-imports

# 3. With Vite running (`npx vite --host 127.0.0.1 --port 5179`) and playwright-core installed:
CREATION_WEB_URL=http://127.0.0.1:5179 node tests/browser/assistant_wait_outcome.mjs

Expected highlights:

  • until="any" (1 succeeded + 1 running, waitSeconds=60) and waitSeconds=0 (1 running) both report satisfied: true, settled: false, count in 5/5 complete / 5/5 已完成, and render as Jobs running / 仍有任务运行 rather than Not finished / 未结束.
  • until="all" (waitSeconds=60, 2 running) reports satisfied: false, settled: false, counts in 5/5 complete / 5/5 已完成, and renders as Not finished / 未结束 with summary 1 wait not finished / 1 次等待未结束.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant