Stop showing the held tool call as running during a pause

This commit is contained in:
Ian Gulliver
2026-10-22 22:14:19 -07:00
parent 293c21ca8c
commit 11e21bcf18
6 changed files with 42 additions and 12 deletions
+19 -5
View File
@@ -131,7 +131,15 @@ func (m *Manager) isPaused(sessionID string) bool {
return m.paused[sessionID] != nil
}
func (m *Manager) holdWhilePaused(ctx context.Context, l *live) bool {
func hookToolUseID(input json.RawMessage) string {
in := struct {
ToolUseID string `json:"tool_use_id"`
}{}
json.Unmarshal(input, &in)
return in.ToolUseID
}
func (m *Manager) holdWhilePaused(ctx context.Context, l *live, toolUseID string) bool {
held := false
for {
m.mu.Lock()
@@ -141,7 +149,13 @@ func (m *Manager) holdWhilePaused(ctx context.Context, l *live) bool {
return held
}
if !held {
slog.Info("agent held by pause", "session", l.id)
slog.Info("agent held by pause", "session", l.id, "tool_use_id", toolUseID)
if toolUseID != "" {
err := m.emit(context.WithoutCancel(ctx), l, agentActor, "agent.held", map[string]any{"tool_use_id": toolUseID})
if err != nil {
slog.Error("record held tool call", "session", l.id, "err", err)
}
}
}
held = true
select {
@@ -152,13 +166,13 @@ func (m *Manager) holdWhilePaused(ctx context.Context, l *live) bool {
}
}
func (m *Manager) heldBeforeTool(ctx context.Context, l *live) bool {
return m.holdWhilePaused(ctx, l) && ctx.Err() == nil
func (m *Manager) heldBeforeTool(ctx context.Context, l *live, toolUseID string) bool {
return m.holdWhilePaused(ctx, l, toolUseID) && ctx.Err() == nil
}
func (m *Manager) beforeTool(l *live) hookcmd.Func {
return func(ctx context.Context, input json.RawMessage) (map[string]any, error) {
if !m.heldBeforeTool(ctx, l) {
if !m.heldBeforeTool(ctx, l, hookToolUseID(input)) {
return map[string]any{}, nil
}
mt := m.deliverMidTurn(ctx, l)