From aff958bca900ed41269a84c1ffa9be8ed8d60847 Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Thu, 7 May 2026 17:02:55 +0800 Subject: [PATCH] fix: extend openclaw wait timeout --- internal/acp/orchestrator.go | 6 ++++-- internal/acp/routing_test.go | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/internal/acp/orchestrator.go b/internal/acp/orchestrator.go index d067a48..e015505 100644 --- a/internal/acp/orchestrator.go +++ b/internal/acp/orchestrator.go @@ -20,6 +20,8 @@ type SessionOrchestrator struct { server *Server } +const openClawAgentWaitTimeout = 9 * time.Minute + func NewSessionOrchestrator(server *Server) *SessionOrchestrator { return &SessionOrchestrator{server: server} } @@ -219,9 +221,9 @@ func (o *SessionOrchestrator) runOpenClawGatewayChat( "agent.wait", map[string]any{ "runId": runID, - "timeoutMs": 120000, + "timeoutMs": openClawAgentWaitTimeout.Milliseconds(), }, - 2*time.Minute, + openClawAgentWaitTimeout, notifyWithCollection, ) if !waitResult.OK { diff --git a/internal/acp/routing_test.go b/internal/acp/routing_test.go index 267a82f..7f9a486 100644 --- a/internal/acp/routing_test.go +++ b/internal/acp/routing_test.go @@ -498,6 +498,17 @@ func TestExecuteSessionTaskGatewayAutoConnectsLocalOpenClaw(t *testing.T) { if gateway.AgentWaitCount() != 1 { t.Fatalf("expected one OpenClaw agent.wait request, got %d", gateway.AgentWaitCount()) } + waitParams := gateway.LastAgentWaitParams() + timeoutMs, ok := waitParams["timeoutMs"].(float64) + if !ok { + t.Fatalf("expected numeric OpenClaw agent.wait timeoutMs, got %#v", waitParams) + } + if got := int64(timeoutMs); got != openClawAgentWaitTimeout.Milliseconds() { + t.Fatalf("expected OpenClaw agent.wait timeoutMs %d, got %#v", openClawAgentWaitTimeout.Milliseconds(), waitParams) + } + if got := int64(timeoutMs); got <= 120000 { + t.Fatalf("expected OpenClaw agent.wait timeout to exceed the previous 120s cap, got %#v", waitParams) + } if gateway.ArtifactExportCount() != 1 { t.Fatalf("expected one OpenClaw artifact export request, got %d", gateway.ArtifactExportCount()) } @@ -1552,6 +1563,7 @@ type acpFakeOpenClawGateway struct { artifactReadFailures atomic.Int32 lastConnectClient atomic.Value lastArtifactExportParams atomic.Value + lastAgentWaitParams atomic.Value mu sync.Mutex methods []string runMessages map[string]string @@ -1700,6 +1712,7 @@ func newAcpFakeOpenClawGateway(t *testing.T) *acpFakeOpenClawGateway { case "agent.wait": fake.agentWaitCount.Add(1) params := shared.AsMap(frame["params"]) + fake.lastAgentWaitParams.Store(params) runID := strings.TrimSpace(shared.StringArg(params, "runId", "fake-run")) switch fake.runMessage(runID) { case "wait-error": @@ -1983,6 +1996,11 @@ func (f *acpFakeOpenClawGateway) AgentWaitCount() int { return int(f.agentWaitCount.Load()) } +func (f *acpFakeOpenClawGateway) LastAgentWaitParams() map[string]any { + params, _ := f.lastAgentWaitParams.Load().(map[string]any) + return params +} + func (f *acpFakeOpenClawGateway) ArtifactExportCount() int { return int(f.artifactCount.Load()) }