startToolsetWithTimeout starts a toolset under a bounded deadline, mirroring listToolsWithTimeout. The deadline must be enforced by racing the call against the timeout (not only via the context): the MCP connector detaches the context it is handed with context.WithoutCancel, so a wedged initialize h
(ctx context.Context, toolset *tools.StartableToolSet, timeout time.Duration)
| 1720 | // becomes usable on the next turn; if it never does, the TUI shutdown safety |
| 1721 | // net still bounds the exit path. |
| 1722 | func startToolsetWithTimeout(ctx context.Context, toolset *tools.StartableToolSet, timeout time.Duration) error { |
| 1723 | if timeout <= 0 { |
| 1724 | timeout = defaultToolStartTimeout |
| 1725 | } |
| 1726 | startCtx, cancel := context.WithTimeout(ctx, timeout) |
| 1727 | defer cancel() |
| 1728 | |
| 1729 | done := make(chan error, 1) // buffered so a late send never blocks |
| 1730 | go func() { |
| 1731 | done <- toolset.Start(startCtx) |
| 1732 | }() |
| 1733 | |
| 1734 | select { |
| 1735 | case <-startCtx.Done(): |
| 1736 | return startCtx.Err() |
| 1737 | case err := <-done: |
| 1738 | return err |
| 1739 | } |
| 1740 | } |
| 1741 | |
| 1742 | func (r *LocalRuntime) Resume(_ context.Context, req ResumeRequest) { |
| 1743 | slog.Debug("Resuming runtime", "agent", r.currentAgentName(), "type", req.Type, "reason", req.Reason) |
no test coverage detected