MCPcopy Index your code
hub / github.com/docker/docker-agent / TestYoloMode_OverridesSessionDeny

Function TestYoloMode_OverridesSessionDeny

pkg/runtime/runtime_test.go:2513–2558  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2511}
2512
2513func TestYoloMode_OverridesSessionDeny(t *testing.T) {
2514 t.Parallel()
2515
2516 // Test that --yolo flag takes precedence over session-level deny
2517 var executed bool
2518 agentTools := []tools.Tool{{
2519 Name: "blocked_tool",
2520 Parameters: map[string]any{},
2521 Handler: func(_ context.Context, _ tools.ToolCall) (*tools.ToolCallResult, error) {
2522 executed = true
2523 return tools.ResultSuccess("executed"), nil
2524 },
2525 }}
2526
2527 prov := &mockProvider{id: "test/mock-model", stream: &mockStream{}}
2528 root := agent.New("root", "You are a test agent",
2529 agent.WithModel(prov),
2530 agent.WithToolSets(newStubToolSet(nil, agentTools, nil)),
2531 )
2532 tm := team.New(team.WithAgents(root))
2533
2534 rt, err := NewLocalRuntime(t.Context(), tm, WithSessionCompaction(false), WithModelStore(mockModelStore{}))
2535 require.NoError(t, err)
2536
2537 sess := session.New(
2538 session.WithUserMessage("Test"),
2539 session.WithToolsApproved(true),
2540 session.WithPermissions(&session.PermissionsConfig{
2541 Deny: []string{"blocked_tool"},
2542 }),
2543 )
2544 require.True(t, sess.ToolsApproved)
2545
2546 calls := []tools.ToolCall{{
2547 ID: "call_1",
2548 Type: "function",
2549 Function: tools.FunctionCall{Name: "blocked_tool", Arguments: "{}"},
2550 }}
2551
2552 events := make(chan Event, 10)
2553 rt.processToolCalls(t.Context(), sess, calls, agentTools, NewChannelSink(events))
2554 close(events)
2555
2556 // With --yolo, the tool should execute despite session deny
2557 require.True(t, executed, "expected tool to be executed in --yolo mode despite session deny permission")
2558}
2559
2560func TestStripImageContent(t *testing.T) {
2561 t.Parallel()

Callers

nothing calls this directly

Calls 15

processToolCallsMethod · 0.95
ResultSuccessFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
WithAgentsFunction · 0.92
NewFunction · 0.92
WithUserMessageFunction · 0.92
WithToolsApprovedFunction · 0.92
WithPermissionsFunction · 0.92
NewLocalRuntimeFunction · 0.85
WithSessionCompactionFunction · 0.85
WithModelStoreFunction · 0.85

Tested by

no test coverage detected