Skip to content

Post-cutover gaps: /api/chat/workflow vs open-agents /api/chat #605

@sweetmantech

Description

@sweetmantech

Tracking issue for gaps surfaced by the open-agents → recoup-api chat workflow cutover (recoupable/open-agents#43). The chat-workflow port replicated the request/response wire format but did not port the post-stream side effects from open-agents' app/workflows/chat.ts + chat-post-finish.ts. Filing each gap as its own follow-up PR.

Must-fix (silent data loss / broken UX / silent revenue loss)

Multi-step + metadata (verify whether streamText.stopWhen covers these, then close as appropriate)

  • Outer multi-step loop vs single-call streamText.stopWhen — verify multi-tool-call traces complete cleanly on api
  • stepFinishReasons[] accumulation across steps in message metadata
  • totalMessageUsage / totalMessageCost carryover across steps
  • Stable messageId across stepsfix(chat-workflow): persist the assistant message after a successful run #609 (workflow-body generateAssistantMessageId step threaded through every runAgentStep call; resume-aware reuse for in-progress assistant turns)

Lifecycle / observability

  • workflow_runs row via recordWorkflowRun — chat workflows have no workflow-run telemetry on api (status, durationMs, stepTimings). Separate from the credits gap above — recordWorkflowUsage in open-agents does BOTH but they're independent concerns
  • refreshDiffCache after workflow finish — diff viewer stays stale until next reload
  • refreshLifecycleActivity per long step — currently refreshed once before start

Product features

  • Auto-commit + push after a natural finish — feat(chat-workflow): auto-commit + push after natural finish #614 (LLM-generated message via gpt-5.4-nano, data-commit UI chunks emit live AND persist onto chat_messages.parts so the GitDataPartCard survives refresh). Three sub-gaps remain blocked on other items: autoCommitEnabled toggle waits on user preferences integration below; wasAborted gating waits on the Stop monitor above; co-author trailer is minor and not blocking.
  • User preferences integration — getUserPreferences → filterModelVariantsForSession → sanitizeSelectedModelIdForSession. Also unblocks autoCommitEnabled toggle on the auto-commit flow.
  • Subagent model resolution — resolveChatModelSelection currently single-model
  • Managed template trial limit (MANAGED_TEMPLATE_TRIAL_MESSAGE_LIMIT enforcement)

Minor

  • dedupeMessageReasoning on inbound messages
  • pruneMessages({emptyMessages: "remove"})
  • reconcileExistingActiveStream — open-agents retries 3× with chat re-fetch; api is single-pass
  • upsertChatMessageScoped — open-agents scopes the PK conflict check to the chat; api's global upsertChatMessage could in principle skip on cross-chat id collision (vanishingly unlikely with ai's generateId)
  • Conflict logging on duplicate upsert — open-agents console.warn when result.status === "conflict"; api silently returns
  • originalMessages threaded into toUIMessageStream — open-agents passes the prior turn for assembly; api doesn't
  • sendStart: false, sendFinish: false + explicit sendStart/sendFinish steps — currently relying on toUIMessageStream defaults (wire format verified identical, but interleaved-step architecture diverges)
  • Writer per-chunk acquisition — open-agents acquires fresh writer per chunk so other steps can interleave writes; api holds one writer for the whole stream
  • streamClosed backup close — open-agents' belt-and-suspenders pattern with a streamClosed flag and a guarded close in finally; api relies on closeChatStream step in finally always running
  • Auto-commit co-author trailer — open-agents appends Co-Authored-By: <GitHub App identity> as a second -m; api currently has no GitHub App equivalent
  • Auto-commit auth URL helper — open-agents has buildGitHubAuthRemoteUrl({token, owner, repo}); api inlines the template literal in performAutoCommit

Acceptance for full deletion of open-agents /api/chat route

All "Must-fix" boxes checked + multi-step verification + (auto-commit OR explicit decision to deprecate that feature).

Source reference: open-agents/apps/web/app/workflows/chat.ts (~1000 lines) + open-agents/apps/web/app/workflows/chat-post-finish.ts (9 exported step functions, including recordWorkflowUsage at line 230).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions