Repository navigation
Service assistant tests drive the scripted driver as Pi works a turn instead of Native - #1303
Conversation
…er capability, not Pi's id serviceHarnessTurn gave its steering (messages merged during the turn, streamed text, a restart after an edit, stay_silent as the ending) only to the driver whose id is `pi`. A driver now declares it with `steered_turns: true` in its registration; Pi does, so production behaves as before. The management assistant's empty-answer check and the group assistant's choice between the steered path and the plain harness turn use the same declaration (`steersServiceTurns`). This lets the test-only scripted driver work a service turn as Pi does, so in-process tests of the assistants check the production semantics. The design doc also states what a harness turn does with a refused tool call: 400/403/404/409/413/415 come back to the model and the turn goes on; 401 and internal failures end it.
…s JSON once The own task's context is already a JSON string. On a harness (Pi, Codex, Claude Code) it was passed through JSON.stringify again, so the session received an escaped string instead of the object the native loop sends.
…n the request names one As for a service role's PATCH, a binding PUT that omits `harness` keeps the saved backend without checking it against the console's list; a backend the request names must still be one the console offers.
… driver as Pi works a turn The management assistant and bound groups in the management, channel and onboarding fixtures run the test-only scripted driver instead of Native. It declares `steered_turns` and works a service turn in process as Pi does: tools through the harness tool dispatcher, messages taken before the first request and after each tool batch, a streamed answer, a model step reported as it starts, a restart after an edit, stay_silent as the ending. Its turns borrow an empty session workspace from the assistant computers the fixtures lack. A binding is saved through the API, which offers only the production backends, and then switched in the store (`scriptedGroup`). Changed assertions follow what Pi does in production: - refusals (403, business-state 409) come back to the model and the turn completes; the refused call still does nothing (maintainers' decision on agent-CI-Infra#1256). The fixture model reports an error observation instead of claiming success; - a refused stay_silent is `invalid_submission` with code `reply_required`; - an own task on a harness is also offered `finish`; - a harness turn takes its owner's computer as it starts (agent-CI-Infra#1254), so the checks that memory tools and a read-only operator start no container now check that no command ran on it; - group turns record no `model_done`. Cases that check what only the native loop does stay on Native and go with it in agent-CI-Infra#1257: its image recovery and request fitting (3 in channel-media), admission closing at a stream's finish marker (channel-turn-messages), and the Native halves of the agent-CI-Infra#333 batch budget and agent-CI-Infra#533 refusal cases, which now also run on the scripted driver.
|
CI: the first
The CI unit shard times are now in the description (Test time): that runner was about 42 % slower across all sets, and the migrated sets were no slower than the rest. |
检视结论:1 项必须修复(头部提交的
|
|
Enqueued on the reviewed head Checks on this head: On the earlier blocking review citing the first
No blocking code issue remains from my review: the declared Non-blocking follow-ups (not required for this merge):
Reviewed commit: 0550ae0 |
e52008a
Fixes #1256
Third and last of three PRs for #1256; #1289 and #1291 are merged. The service-assistant tests (management assistant, bound groups) no longer run the control-plane Native loop: they drive the test-only scripted driver, which now works a service turn the way Pi does in production. After this PR, Native runs in tests only where a case checks what only Native does; #1257 removes those with Native.
Maintainers' decisions on the Issue: 1 (choose the Pi service-turn protocol by a declared driver capability) and 2 (accept Pi's handling of refused tool calls).
What changes
Steering by declared capability (
src/roles/harness.ts,src/harness/service-session.ts,src/management/agent.ts,src/channels/service-session.ts):serviceHarnessTurngave its steering (messages merged during the turn, streamed text, a restart after an edit,stay_silentas the ending) only to the driver whose id ispi. Every other driver got afinishtool and none of it. The management assistant's empty-answer check and the group assistant's choice of path also compared the id withpi.steered_turns: truein its registration and the three places read that (steersServiceTurns). Pi declares it, so production behaves as before. The scripted test driver declares it too.Own tasks on a harness get their context once (
src/service-roles/own-tasks.ts): an own task's context is already a JSON string, and on a harness (Pi, Codex, Claude Code) it went throughJSON.stringifyagain, so the session got an escaped string instead of the object. The migrated testpersonal-management"works a side question in its own task" found it (it readsinstructionfrom the prompt).Group binding PUT (
src/channels/service-bindings.ts): as for a service role's PATCH, a request that omitsharnesskeeps the saved backend without checking it against the console's list; a backend the request names must still be one the console offers. A test saves a binding through the API and then switches it toscriptedin the store, and later re-saves must still pass.The scripted driver's service turn (
test/fixtures/scripted-driver.mjs): a spec fromserviceHarnessTurn(the only one with theassistantenvironment profile) runs a loop of its own, modelled onrunner/pi-entry.mjsandsrc/agent/pi.ts:createTaskToolDispatcher, as on Pi: correctable refusals come back as observations, each result is bounded by itself, tool images return with the observation,finish/stay_silentend the turn with their submission;spec.pi.service): messages taken before the first request and after each tool batch join as user messages, the answer streams throughtext, each response reportsresponded, and an edit throws from the steering or a tool call soserviceHarnessTurnrestarts;model_start), as Pi's runner does (Management assistant on Pi: show native tool and model progress in the conversation #1296);invalid_arguments.processworker loop from Role and task tests drive their fake model through a test-only scripted driver instead of Native #1291.Fixtures:
management-fixture,channel-fixture(boundGroup) andonboarding-fixture(assistantModel) put the management assistant and bound groups onscripted. Their turns, and those ofidentity-fixture, borrow an empty session workspace from the assistant computers the fixtures lack.scriptedGroupswitches a saved binding. The fixture model's default answer reports an error observation instead of claiming success, since refusals now reach it.native-roles.mjskeeps onlynativeServiceAssistants, for the Native-only cases below.Changed assertions
Only assertions that described Native's behavior change, to what Pi does in production:
management-tool-recovery(2),personal-management(read-only and out-of-scope),channels(3),feishu-collaborators(Read collaborator),repository-onboarding-requests(decided meanwhile).managementOutcomegainsrefused, the last refused call's code.stay_silentisinvalid_submissionwith codereply_required(channel-silent-turns).finish(personal-management).channel-assistant-computer,service-roles);service-roleswaits for both computers to go idle.model_done(assistant-model-retry).channel-service-bindings,channel-conversationand two e2e specs (channel-console,channel-conversation) saved bindings asnativefor the fixture model; they usescriptedGroupnow.Left on Native until #1257
Cases that check what only the native loop does, pinned with
nativeServiceAssistantsor a binding saved asnative:channel-media(3): the native loop's own image recovery and request fitting. Pi's are covered bymultimodal-harness.channel-turn-messages"an empty model answer closes admission at its finish marker": the native loop closes admission at the stream's finish marker; Pi closes it when the whole response has arrived, and a message admitted meanwhile returns to the queue when the turn finishes.management,channel-service-bindings: one tool batch sharing one result budget; 服务助手用 Pi 时补齐 Native 的四项能力:流式文字、回合中并入新消息、编辑后重启、保持安静 #1253 replaced it on Pi with per-result bounds, compaction and result files) and of the two [治理] 清理 #521 同类过度防御的权限围栏、静默吞错与保守永久锁死(会话/记忆清空、预算 unknown 锁仓、配置死锁) #533 refusal cases (management-tool-recovery). Each now runs on both drivers: shared assertions on both, Native-only ones on Native.Not in this PR, per #1291's rule that tests configuring
nativeexplicitly for project roles stay until #1257:channel-task-engineruns a group employee's project role and QA on Native (harness_ref: native). #1257 should move it to the scripted driver rather than delete it, since it covers shared task execution.Tests
On head
0550ae05(basemain@45e5c7df):npm run check: exit 0.45e5c7dfonly moves task failure guidance intosrc/agent/failure-actions.tsand shares no file with this PR.Earlier heads with the same changes:
npm testonb36b7d22(the same head before two test fixes, see below): 2648 of 2657 passed at load average 12–17. Failed sets:codex-harness(its two grace-period checks; they also failed in the baseline run onmain, 67/67 alone right after);repository-skills-request(90 s timeout) andassistant-computer-turns(its 助手电脑预热:Pi 服务助手的每一轮不再等冷启动 #1254 give-back case readbusy): not touched here, both pass alone right after, and Role and task tests drive their fake model through a test-only scripted driver instead of Native #1291 saw both fail under load;repository-onboarding-requestsandservice-roles: two mistakes in this PR's own test changes, fixed ind4eb21f1.service-rolesnow waits only for the administrator's computer: under load the read-only reader's turn can end before the computer it started to take is ready (the same give-back path as theassistant-computer-turnscase).d4eb21f1(both fixes in): the same 51 files 508/508;service-roles3 runs at once: pass.d4eb21f1, 4 workers: the 38 specs that use those fixtures: 179/181. The two failures werechannel-console"real messages, steps and binding counts" at both widths: it listed the Native-only "模型已返回" step. After dropping it (2a41d785), that spec 15/15.Test time (Issue requirement 4):
npm test, same host, one after the other:main900ae1f5: 573 s wall, summed set time 6873 s, load average 6.4 at the start;b36b7d22: 700 s wall, summed set time 7464 s, load average 11.8 at the start and up to 17.main951 s summed (72 s wall), this PR 913 s (69 s wall). The scripted driver's service turn is not slower than Native; the four cases that now run on both drivers add a few seconds.unitshards (job time of the slower shard per run): the last five merge-group runs before this PR took 356–511 s, median 459 s (89a5c564: 311 s / 356 s). This PR (0550ae05): 413 s / 521 s. That runner was slower across the board: per the shard artifacts, against89a5c564's merge group the 255 sets this PR does not touch took 42.3 % longer and the 51 migrated sets 40.7 % longer, so relative to the rest the migrated sets did not slow down.test-set-weights.jsonis unchanged.