(sessionState *SubAgentSessionState, currentText string)
| 403 | } |
| 404 | |
| 405 | func (s *SubAgent) partialTimeoutText(sessionState *SubAgentSessionState, currentText string) string { |
| 406 | var sections []string |
| 407 | if strings.TrimSpace(currentText) != "" { |
| 408 | sections = append(sections, "Partial assistant text:\n"+strings.TrimSpace(currentText)) |
| 409 | } else if text := latestAssistantText(sessionState.Messages); text != "" { |
| 410 | sections = append(sections, "Latest assistant text:\n"+text) |
| 411 | } |
| 412 | if observations := formatRecentSubagentObservations(sessionState.RecentToolObservations, 6); len(observations) > 0 { |
| 413 | sections = append(sections, "Recent tool observations:\n"+strings.Join(observations, "\n")) |
| 414 | } |
| 415 | if len(sections) == 0 { |
| 416 | sections = append(sections, "No text or tool observations were produced before the timeout.") |
| 417 | } |
| 418 | return fmt.Sprintf("Sub-agent reached its %ds timeout and is returning partial progress instead of a tool error.\n\n%s", s.timeoutSeconds(), strings.Join(sections, "\n\n")) |
| 419 | } |
| 420 | |
| 421 | func (s *SubAgent) wrapTimedOutResult(text string) string { |
| 422 | text = strings.TrimSpace(text) |
no test coverage detected