backgroundAuthRequiredNote returns a model-readable note naming the child agent's MCP toolsets that could not start because they require first-time interactive OAuth authorization, which a background agent cannot complete (issue #3200). It returns "" when no toolset is in that state. Detection is ty
(child *agent.Agent)
| 422 | // LastError) rather than string-matched, so it stays correct if the user-facing |
| 423 | // error text changes. |
| 424 | func backgroundAuthRequiredNote(child *agent.Agent) string { |
| 425 | var needAuth []string |
| 426 | for _, ts := range child.ToolSets() { |
| 427 | status := toolsetStatusFor(ts) |
| 428 | if mcptools.IsAuthorizationRequired(status.LastError) { |
| 429 | needAuth = append(needAuth, status.Name) |
| 430 | } |
| 431 | } |
| 432 | if len(needAuth) == 0 { |
| 433 | return "" |
| 434 | } |
| 435 | return fmt.Sprintf( |
| 436 | "Note: the following MCP tool server(s) could not be used because they "+ |
| 437 | "require first-time interactive OAuth authorization, which cannot be "+ |
| 438 | "completed by a background agent: %s. Ask the user to authorize them "+ |
| 439 | "once from an interactive session (run the agent in the foreground and "+ |
| 440 | "approve the OAuth prompt), then retry this task.", |
| 441 | strings.Join(needAuth, ", "), |
| 442 | ) |
| 443 | } |
| 444 | |
| 445 | // persistBackgroundSubSession writes a completed background sub-session to the |
| 446 | // session store, linking it under parentID. It is the runCollecting analogue |
no test coverage detected