Skip to Content
Recodocs

On follow-up, two argument-free reads or an answer

A property-photo desk stays governable when, on a follow-up, the model may call get_report, call view_image, or answer, both tools take arguments {}, and the host owns the schema, the session and the budget.

7 min read

Separate an observed or scripted report from the advice the assistant gives based on it. This test shows the intended evidence path under fixtures; it does not establish that a model can independently diagnose a real property defect.

A scripted test uploads a photo. The contract test's fake client returns a fixture report whose summary is "A visible crack needs inspection." The scripted question is, "What should I do?" The fake client then returns a get_report call and the fixed sentence "On-site inspection is needed."

A scripted second upload of a different photo to the same session is refused with a 409 before any model runs.

The claim is that a property-photo desk is governable when, on a follow-up, the model may call get_report, call view_image, or answer, both tools take arguments {}, and the host owns the report schema, the session, the call budget and the refusals. The host-side guards do not depend on which model is used.

The argument

  1. Findings are a schema. Photo inspection is one model call whose output must validate as Report. Anything else is a failed operation, never a partial answer.
  2. Only the follow-up is an agent. In Engine.answer the model chooses, turn by turn, between get_report, view_image and an answer. Inspection is a separate schema-validated call and does not offer those tools.
  3. The tools carry no model-supplied value. Arguments must be exactly {}. A model that tries to name another inspection gets a fault, not a lookup.
  4. Spend is reserved before the wire. The call counter increments before the request leaves, so an ambiguous timeout cannot be replayed for free.

Who is allowed to decide

The tempting design hands the multimodal model a camera and a ledger: let it fetch files, rewrite state and narrate safety. It gives the model reach the host would then have to police. This desk splits the work in two. Inspection is one structured call with no tools. Follow-up is a short loop whose every step is checked by the host.

The figure shows the order of those checks. The Client card, labelled demo-ui, meets the dashed property_demo process on the POST arrow. Five stages follow: SessionGuard (origin, bearer, lease), analyze (Report JSON schema), Engine.answer (tool_choice auto), Tool gate (two reads, one turn), and Limits (calls, turns, busy). The guard and Engine.admit run before a model call; analyze and Engine.answer are the calls. Inspection calls the model from analyze; a follow-up calls it from Engine.answer, which also checks the tool.

What the runtime owns before the model choosesA browser client sends a photo or question into a dashed process. SessionGuard runs first, then a single structured inspection call, then the bounded follow-up loop in Engine.answer with an allowlisted tool gate and session limits.Clientdemo-uiX-Request-IDBearer sessionproperty_demoRuntimeSessionGuardorigin, bearer, leaseanalyzeReport JSON schemaEngine.answertool_choice autoTool gatetwo reads, one turnLimitscalls, turns, busySession dirstate.jsonphoto.jpgmanifest.jsonModel routeCodexChatClientgpt-5.6-luna default35 s timeoutPOST202 opwritescalls
Caption: auth and budgets sit outside the model; only follow-up tool choice is model-driven.

The guard is not an agent. Inspection is the analyze call; the follow-up agent is Engine.answer. SessionGuard compares the bearer token in constant time and honours the lease expiry before any work starts. Limits caps turns, calls, and concurrency: three model turns per follow-up, thirty model calls per session, and one concurrent request. Engine.call increments model_calls, and Engine.admit rejects a busy or exhausted session before the task starts. A system prompt sets triage and tool-use policy; the host still rejects any tool outside the two reads. The local route is the Codex grant with gpt-5.6-luna as the default model, and startup fails if that model is not in the grant catalog. There is no API-key fallback.

The follow-up prompt also treats the model's own earlier output with suspicion. The stored report summary goes back in labelled "untrusted evidence", alongside at most eight recent messages.

What the evidence shows

The strongest guard is a small one. Both tools take no arguments, so the model has nothing to steer with. That makes the failure cases easy to list, and the tests list them.

How Engine.answer rejects a tool callFour steps from a model turn to either get_report, view_image, or a terminal fault. Unknown names, extra arguments, duplicate reads, or exhausted turns never return an answer.Model turntool_calls[0]Allowlistget_report · view_imageExecuteempty args onlyOutcomeanswer or Faultparallel offmax 3 turnsTOOL_NAMESdelete_filesget_report → JSONview_image → photoselected_by: modelinvalid_toolno_progressturn_limitTests in tests/test_property.py parametrize the fault codes the loop must emit.
Caption: two read-only tools per inspection; everything else is a typed failure.

Read the figure left to right. A model turn yields at most one tool call, with parallel calls turned off. The name must be in the allowlist. The arguments must be empty. An allowed turn ends in an answer or in invalid_tool, no_progress, or turn_limit; the loop can also fail with invalid_output or a provider fault. The struck-through delete_files is the example the tests use.

One test, test_model_tools_are_bounded, runs four hostile replies against a real upload and checks the fault code each time:

Model replyFaultWhy
Calls delete_filesinvalid_toolName is outside the allowlist
Calls get_report with an inspection_id of otherinvalid_toolArguments must be empty
Calls get_report twice in a rowno_progressA repeated read advances nothing
Calls view_image with a one-turn budgetturn_limitThe turn budget ended without an answer

In every row the operation fails and the answer is None. A queued get_report call whose arguments are {"inspection_id":"other"} fails invalid_tool before a lookup. Evidence reads are fixed too. get_report returns the stored report. view_image attaches the current session photo as a user message. The model supplies no path and no URL.

The inspection path has its own guards. Unstructured text fails the operation as invalid_output, and inspection["report"] stays None. When the provider times out, the failed operation is terminal: a repeat of the same request returns the same failure, only one model call is counted, and no report is stored. When the model-call limit is one, a follow-up is refused with a 429. These outcomes come from the runtime. None of them depends on the model's cooperation.

The boundary is the same for access. The tests send a different session token, an empty authorization header and an origin that is not allowed, and expect 401, 401 and 403. Image bytes are replaced by [image bytes omitted] in the observability spans, and the list route leaves out trace payloads.

What would falsify the claim is a test in which a disallowed tool runs, a non-Report inspection succeeds, or a timeout leaves its reservation unspent. The parametrised cases cover the tool faults; invalid report JSON and the consumed timeout reservation are two other tests. What the suite cannot show is how often a real model reaches for the wrong tool. The contract tests use a fake client. Live Codex evidence in docs/kit-migration.md is a separate single-photo smoke. Local tests exercise the Bedrock client, bridge, and cloud app with fakes; they do not launch the AWS AgentCore stack.

The turn we ran

The happy path is one async test that chains upload, inspection, follow-up, deduplication and isolation. The fake client queues three replies: a report, a get_report call, and the sentence "On-site inspection is needed."

Happy path exercised in test_real_contract_dedupe_tools_and_isolationPOST /v1/inspectionsdedupe request_idanalyzeReport schemafollowupget_reportoperationsucceededFake client: one inspection call, one tool turn, one final answer; repeat followup returns the same operation id.
Caption: the contract test path from upload through a single allowlisted tool.

Four boxes run left to right: the upload with its request id, analyze under the Report schema, the follow-up that calls get_report, and an operation that ends as succeeded. The note beneath says the fake client sees one inspection call, one tool turn and one final answer, and that a repeated follow-up returns the same operation.

The counts make the point. After the upload, the client has been called once, with store set to false. After the follow-up it has been called three times: the inspection, the tool turn and the answer. Repeating the follow-up with the same request id does not make a fourth call, because the host returns the finished operation. Activity on that operation lists a single tool event, get_report.

The same test then probes the edges. Another inspection id returns 404 on the image route. A request bound to another session is denied. The session's state.json on disk must not contain the runtime key. Each is a statement about the host, and the model is not in the room for any of them.

The one check to copy

Copy the shape, not the property nouns. After every model turn that asks for a tool, keep only names in a frozen set, require arguments equal to {}, refuse a repeat, and fail closed when the turns run out without an answer.

@pytest.mark.parametrize(
    "replies,code",
    [
        ([Reply(tool="delete_files")], "invalid_tool"),
        ([Reply(tool="get_report", args='{"inspection_id":"other"}')], "invalid_tool"),
        ([Reply(tool="get_report"), Reply(tool="get_report")], "no_progress"),
        ([Reply(tool="view_image")], "turn_limit"),
    ],
)
async def test_model_tools_are_bounded(tmp_path, replies, code):
    ...
    assert failed["status"] == "failed" and failed["error"]["code"] == code
    assert failed["answer"] is None

The production loop checks the same things: one call per turn, a name in {"get_report", "view_image"}, empty arguments, no repeat, and turn_limit when the budget ends. A medical-imaging desk would swap the schema and the two reads and keep the rest. The host lists the reads, the model picks among them, and unknown names, non-empty arguments, repeated reads, and the turn budget are typed faults with tests; several other engine faults have no matching assertion.

Close

A property demo invites talk of "the AI inspector." The code describes something smaller. In the contract test the fake client returned a Report, then one get_report call, then a fixed answer sentence. The host decided who the session belongs to, how large the photo may be (at most 1280 pixels after resizing), which calls count against the budget and which tool names may run. Findings help triage. They never certify structural safety; the README says so, and the system prompt tells the model never to certify structural safety. The limitations field is a string of 1–800 characters, and the schema does not require the fixture sentence. The sentence "A photo cannot establish structural safety." is the test fixture's limitations string.

To extend the desk, add a host-owned read with a test that proves unknown names still fail. Do not widen what the prompt politely declines. Keep inspection structured, keep the follow-up bounded in Engine.answer, and treat any live run as evidence separate from the fake-client suite.

How is this page?

Last updated on