MCPcopy Create free account
hub / github.com/docker/docker-agent / TestResolveSessionAgent_PinnedAgent

Function TestResolveSessionAgent_PinnedAgent

pkg/runtime/runtime_test.go:2763–2780  ·  view source on GitHub ↗

TestResolveSessionAgent_PinnedAgent verifies that resolveSessionAgent returns the session-pinned agent when AgentName is set, even though the runtime's currentAgent points elsewhere (root). Before the fix, the shared currentAgent field was always used, so background sub-agent tasks ran with root's c

(t *testing.T)

Source from the content-addressed store, hash-verified

2761// currentAgent points elsewhere (root). Before the fix, the shared currentAgent
2762// field was always used, so background sub-agent tasks ran with root's config.
2763func TestResolveSessionAgent_PinnedAgent(t *testing.T) {
2764 t.Parallel()
2765
2766 prov := &mockProvider{id: "test/mock-model", stream: &mockStream{}}
2767 worker := agent.New("worker", "Worker agent", agent.WithModel(prov))
2768 root := agent.New("root", "Root agent", agent.WithModel(prov))
2769 tm := team.New(team.WithAgents(root, worker))
2770
2771 rt, err := NewLocalRuntime(t.Context(), tm, WithSessionCompaction(false), WithModelStore(mockModelStore{}))
2772 require.NoError(t, err)
2773 assert.Equal(t, "root", rt.CurrentAgentName(t.Context()), "default agent should be root")
2774
2775 // Session pinned to worker (as run_background_agent does).
2776 sess := session.New(session.WithAgentName("worker"))
2777
2778 resolved := rt.resolveSessionAgent(sess)
2779 assert.Equal(t, "worker", resolved.Name(), "resolveSessionAgent should return pinned agent")
2780}
2781
2782// TestResolveSessionAgent_FallsBackToCurrentAgent verifies that when no
2783// AgentName is set on the session, resolveSessionAgent falls back to the

Callers

nothing calls this directly

Calls 12

CurrentAgentNameMethod · 0.95
resolveSessionAgentMethod · 0.95
NewFunction · 0.92
NewFunction · 0.92
WithAgentsFunction · 0.92
NewFunction · 0.92
WithAgentNameFunction · 0.92
NewLocalRuntimeFunction · 0.85
WithSessionCompactionFunction · 0.85
WithModelStoreFunction · 0.85
ContextMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected