Commit e17cd6e
fix: make A2A client timeout configurable in MCP handler (#1617)
## fix: make A2A client timeout configurable in MCP handler
### Problem
The MCP handler's `invoke_agent` tool uses an A2A client with a
**hardcoded 30-second timeout** (`mcp_handler.go:212`). When an agent
performs multi-step work — schema exploration, multiple tool calls, LLM
reasoning — the total round-trip easily exceeds 30 seconds. The A2A
client times out and returns:
```
Failed to send A2A message: a2aClient.SendMessage: a2aClient.doRequest:
http request failed: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
```
The agent itself completes successfully (visible in pod logs), but the
caller never receives the response.
### Root Cause
Other A2A call sites already use configurable timeouts:
| Call site | Timeout source |
|---|---|
| `a2a_registrar.go` | `cfg.Streaming.Timeout` (default 600s) ✅ |
| CLI `agent invoke` | `cfg.Config.Timeout` ✅ |
| CLI `agent run` | `cfg.Config.Timeout` ✅ |
| **`mcp_handler.go`** | **Hardcoded `30 * time.Second`** ❌ |
The MCP handler was the only place with a hardcoded value.
### Fix
- Add `a2aTimeout time.Duration` parameter to `NewMCPHandler()`
- Pass `cfg.Streaming.Timeout` from `app.go` (same source as the A2A
registrar)
- Fall back to 60s if a zero/negative value is passed
- No new config keys — uses the existing `STREAMING_TIMEOUT` env var /
`--streaming-timeout` flag
### Changes
- `go/core/internal/mcp/mcp_handler.go` — new field, new constructor
param, use `h.a2aTimeout` instead of hardcoded value
- `go/core/pkg/app/app.go` — pass `cfg.Streaming.Timeout` to
`NewMCPHandler()`
### Testing
- `go build ./core/...` passes
- Manually verified with a kagent agent performing 5+ tool calls (~40s
total) — `invoke_agent` now returns successfully
Signed-off-by: Oswaldo Gomez <papagala@users.noreply.github.com>
Co-authored-by: Oswaldo Gomez <papagala@users.noreply.github.com>
Co-authored-by: Eitan Yarmush <eitan.yarmush@solo.io>1 parent 1bf4617 commit e17cd6e
2 files changed
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
60 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
| 72 | + | |
64 | 73 | | |
65 | 74 | | |
66 | 75 | | |
| |||
209 | 218 | | |
210 | 219 | | |
211 | 220 | | |
212 | | - | |
| 221 | + | |
213 | 222 | | |
214 | 223 | | |
215 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
| 536 | + | |
536 | 537 | | |
537 | 538 | | |
538 | 539 | | |
| |||
0 commit comments