Skip to content

[FEATURE]: One source each for the run slot and the forwarded-header lookup, and seed fields that can't pass for live ones #792

Description

@justintime4tea

Summary

Cleanup from the review of PR #719 (#628), with no behavior change. Each item is a place where two things agree only by convention, or where the compiler accepts the wrong one.

Goals

  • Seed fields can't be read as live state. Agent derefs to PreparedAgent, which puts the seed fields scratchpad_budget and turn_nudge beside the scratchpad_budget() and turn_nudge() methods, which return the run's live state. Forget the parentheses and it compiles, but reads a budget that never moves. Rename the fields seed_scratchpad_budget and seed_turn_nudge. Deref stays; dropping it would churn the orchestrator's field reads for no gain.
  • One source for the run slot. add_all_tools gets the slot from its run parameter, and also from config.scratchpad_tools_config.run for the scratchpad read tools and read_artifact. The two match only by convention, and tests already pass different ones. Drop ScratchpadToolsConfig.run so those tools read the slot begin_run binds, by construction. ScratchpadBuildInputs.run stays: it feeds the wrapper build_scratchpad builds, which is a separate path.
  • One forwarded-header lookup. ForwardedHeaders::of and resolve repeat the case-insensitive lookup in apply_request_header_mappings, and walk the same headers_from_request maps as resolve_mcp_headers_in and the HITL webhook route's mapping. The credential check begin_run makes is only right while they agree, so derive both from one lookup helper and one walk of the mappings.
  • prepare says what it takes from a request. Its doc says nothing in it depends on a request, but additional_tools (the server's per-run tools), client_tools and session_id all come from one. State that, and that an agent prepared with them is safe for one request until [FEATURE]: A prepared agent stays warm across a session's runs #787 moves or keys them.

Additional Context

Reported in the review of PR #719: #719 (comment) (items 10, 11, 12, and the doc half of 4). The other half of item 4, keeping request-scoped tools out of a warm prepared agent, is in #787.

Searched Issues

  • No similar issues found

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions