Skip to content

Give a nested run-profile child a deterministic agent route #641

Description

@taras

Problem

A nested <Execution host="run"> child resolves none of the agent words, so a Markdown test suite cannot drive an agent-using document deterministically. Verified on main (7a4d27ea).

Smallest reproducer, via xmd test:

<Test name="a run child resolves Session">
<Execution host="run" source={'<Session name="s">hi</Session>\n'} as="child">
<AssertEquals actual={child.result.ok} expected={false} />
<AssertStringIncludes actual={child.result.error.message} expected="MARKER" />
</Execution>
</Test>
Failed to import component Session: Cannot resolve component: Session (searched: components, .)
Failed to import component Prompt: Cannot resolve component: Prompt (searched: components, .)

Scope

The gap is in the shared child assembly, not in xmd test itself. runProfileChild (packages/cli/src/testing-host.ts) calls installDocumentComponents({ testing: false }, false) — which installs the agent stack only for mode.testing or mode.agent — and passes executeInstalled(..., []) with no agentIdentityComponents(). The same assembly serves every host of the run profile; in practice it is reached from test documents, because <Execution> is valid only inside a canonical <Test> and <Test> bodies run only under an active testing session. Root documents are unaffected: xmd run has the full live stack, and an xmd test root has the agent words plus <TestAgent>.

Wiring alone is not a fix (measured)

Patching the child to add installAgentComponents() and [{ components: agentIdentityComponents() }] moves the failure exactly one step:

Agent.session() has no provider — install one with installAgentComponents({ rootProvider: { factory, options } })

and every channel a child document could use to supply a provider is runtime-proven dead:

  • <AgentProvider name="acpx">Unknown agent provider "acpx" — the registry is scope-local and the child's fresh scope holds no registrations.
  • <TestAgent> → unresolved (registered only under mode.testing), and it refuses outside an active testing session anyway.
  • Providers installed by the enclosing test never reach the child: it runs in a fresh scope (createScope(), packages/testing/src/execution-harness.ts:673), isolation the module header states as design.
  • Repository components shadowing Session/Prompt would resolve through the search path, but substituting the trusted orchestration's words is exactly what the Add xmd prompt: turn a request into an approved executable Plan #260 handoff forbids.

What a fix is

A first-class channel that carries scripted agent behavior (and an elicitation provider) across the execution boundary into the child — an architecture feature with a security surface (what may a test hand a child?), not a wiring change. Until then, the deterministic route for agent-using roots is a TypeScript launcher: executeInstalled on the document as root, with agentIdentityComponents() and scripted Agent/Elicitation providers installed around the call.

Why now

The issue #260 xmd prompt prototype's frozen evidence prefers a Markdown suite under packages/cli/tests/document-suites/prompt/; this gap is why that suite cannot exist yet. Full evidence: issue-260-markdown-prototype-implementor-feedback.md (repo root, untracked). Companion contract issue: #640.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions