Skip to content

Commit 039447f

Browse files
committed
feat(session): add non-interactive mode flag to distinguish from tools approval
- Add `NonInteractive` field to Session struct to explicitly mark sessions running without user interaction - Update runtime loop to use `NonInteractive` instead of `ToolsApproved` for auto-stopping logic - Set non-interactive mode in A2A adapter, evaluation framework, and MCP server - This separates the concept of approved tools from non-interactive execution context
1 parent f1787c4 commit 039447f

5 files changed

Lines changed: 16 additions & 1 deletion

File tree

pkg/a2a/adapter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func runDockerAgent(ctx agent.InvocationContext, t *team.Team, agentName string,
4949
session.WithMaxConsecutiveToolCalls(a.MaxConsecutiveToolCalls()),
5050
session.WithMaxOldToolCallTokens(a.MaxOldToolCallTokens()),
5151
session.WithToolsApproved(true),
52+
session.WithNonInteractive(true),
5253
)
5354

5455
// Create runtime

pkg/evaluation/save.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func SessionFromEvents(events []map[string]any, title string, questions []string
5959
sess := session.New(
6060
session.WithTitle(title),
6161
session.WithToolsApproved(true),
62+
session.WithNonInteractive(true),
6263
)
6364

6465
// Add user questions as initial messages.

pkg/mcp/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ func CreateToolHandler(t *team.Team, agentName string) func(context.Context, *mc
164164
session.WithMaxOldToolCallTokens(ag.MaxOldToolCallTokens()),
165165
session.WithUserMessage(input.Message),
166166
session.WithToolsApproved(true),
167+
session.WithNonInteractive(true),
167168
)
168169

169170
rt, err := runtime.New(t,

pkg/runtime/loop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (r *LocalRuntime) RunStream(ctx context.Context, sess *session.Session) <-c
177177

178178
// In non-interactive mode (e.g. MCP server), auto-stop instead of
179179
// blocking forever waiting for user input.
180-
if sess.ToolsApproved {
180+
if sess.NonInteractive {
181181
slog.Debug("Auto-stopping after max iterations (non-interactive)", "agent", a.Name())
182182

183183
assistantMessage := chat.Message{

pkg/session/session.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ type Session struct {
7676
// ToolsApproved is a flag to indicate if the tools have been approved
7777
ToolsApproved bool `json:"tools_approved"`
7878

79+
// NonInteractive indicates the session is running in a non-interactive context
80+
// (e.g. MCP server, A2A adapter, evaluation framework) where there is no user
81+
// to provide input. This is distinct from ToolsApproved which can also be set
82+
// in interactive TUI sessions when a user approves all tools.
83+
NonInteractive bool `json:"non_interactive,omitempty"`
84+
7985
// HideToolResults is a flag to indicate if tool results should be hidden
8086
HideToolResults bool `json:"hide_tool_results"`
8187

@@ -476,6 +482,12 @@ func WithToolsApproved(toolsApproved bool) Opt {
476482
}
477483
}
478484

485+
func WithNonInteractive(nonInteractive bool) Opt {
486+
return func(s *Session) {
487+
s.NonInteractive = nonInteractive
488+
}
489+
}
490+
479491
func WithHideToolResults(hideToolResults bool) Opt {
480492
return func(s *Session) {
481493
s.HideToolResults = hideToolResults

0 commit comments

Comments
 (0)