Skip to content

feat(flows): Workflows B4 — agent proposes a workflow#4472

Merged
graycyrus merged 1 commit into
tinyhumansai:mainfrom
graycyrus:feat/flows-b4-agent-proposal
Jul 3, 2026
Merged

feat(flows): Workflows B4 — agent proposes a workflow#4472
graycyrus merged 1 commit into
tinyhumansai:mainfrom
graycyrus:feat/flows-b4-agent-proposal

Conversation

@graycyrus

@graycyrus graycyrus commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Talk → workflow. A new propose_workflow agent tool lets the assistant draft a WorkflowGraph; it validates the graph (the same validate_and_migrate_graph path flows_create uses) and returns a summary — it never persists. The chat renders a WorkflowProposalCard; the user's Save (and only that) calls flows_create.

Backend

  • flows/tools.rsProposeWorkflowTool (permission_level None, external_effect false; validate-or-error so the agent self-corrects) + 15 tests. validate_and_migrate_graph made pub(crate); registered in tools/ops.rs.

Frontend

  • WorkflowProposalCard.tsx (+test) — name/trigger/step-badges + Save/Dismiss.
  • flowsApi.createFlow + Flow type; chatRuntimeSlice pendingWorkflowProposalsByThread + reducers; ChatRuntimeProvider onToolResult → dispatch when tool_name==propose_workflow (persists past turn-end, not a blocking gate); Conversations.tsx renders it; i18n chat.flowProposal.* × 14 (distinct namespace — no B3b/B5a conflict).

Human-in-the-loop invariant

No agent/tool code path reaches flows_create — creation is exclusively the user's Save click. Asserted by the tool's permission_level None / external_effect false tests.

Notes

  • tinyflows 0.3 validate only checks structural invariants (unique ids, one trigger, valid edges) — so the tool description carries the per-kind config guidance for the LLM.
  • 2nd commit is a pre-existing fmt/prettier unblock (shared across the B3b/B5a/B4 branches).

Verification

Rust: 15 tool + 271 flows tests pass, tool live in registry. Frontend: typecheck/lint/prettier clean, 8 card + 157 runtime tests pass, i18n parity clean.

Summary by CodeRabbit

  • New Features

    • Added a workflow proposal card in chat to review suggested steps, see triggers, and either save or dismiss the proposal.
    • Added clear loading, error, and approval-required states, plus support for proposals with no additional steps.
  • Bug Fixes

    • Improved handling so proposal state clears correctly after saving, dismissing, or changing threads.
  • Documentation

    • Added multilingual support for the new workflow proposal messages across several locales.

@graycyrus graycyrus requested a review from a team July 3, 2026 20:12
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 97dd66cf-c2b1-43c8-9a29-94eb7bda073c

📥 Commits

Reviewing files that changed from the base of the PR and between a5b6a13 and d5b2fe9.

📒 Files selected for processing (27)
  • app/src/components/chat/WorkflowProposalCard.test.tsx
  • app/src/components/chat/WorkflowProposalCard.tsx
  • app/src/lib/i18n/ar.ts
  • app/src/lib/i18n/bn.ts
  • app/src/lib/i18n/de.ts
  • app/src/lib/i18n/en.ts
  • app/src/lib/i18n/es.ts
  • app/src/lib/i18n/fr.ts
  • app/src/lib/i18n/hi.ts
  • app/src/lib/i18n/id.ts
  • app/src/lib/i18n/it.ts
  • app/src/lib/i18n/ko.ts
  • app/src/lib/i18n/pl.ts
  • app/src/lib/i18n/pt.ts
  • app/src/lib/i18n/ru.ts
  • app/src/lib/i18n/zh-CN.ts
  • app/src/pages/Conversations.tsx
  • app/src/providers/ChatRuntimeProvider.tsx
  • app/src/services/api/flowsApi.ts
  • app/src/store/chatRuntimeSlice.ts
  • app/src/utils/toolTimelineFormatting.ts
  • src/openhuman/flows/mod.rs
  • src/openhuman/flows/ops.rs
  • src/openhuman/flows/tools.rs
  • src/openhuman/flows/tools_tests.rs
  • src/openhuman/tools/mod.rs
  • src/openhuman/tools/ops.rs

📝 Walkthrough

Walkthrough

Adds an agent-facing propose_workflow Rust tool that validates a workflow graph and returns a summary (trigger, steps, approval flag) without persistence, and a corresponding frontend WorkflowProposalCard UI wired through chat runtime state, a new createFlow API call, and chat.flowProposal.* translations across all supported locales.

Changes

Backend propose_workflow tool

Layer / File(s) Summary
Expose validation path
src/openhuman/flows/ops.rs
validate_and_migrate_graph visibility changed to pub(crate) for reuse by the new tool.
ProposeWorkflowTool implementation
src/openhuman/flows/tools.rs
Implements the Tool trait: schema, execute, trigger/step summary building, config hints, and truncation, with no persistence side effects.
Registration and tests
src/openhuman/flows/mod.rs, src/openhuman/tools/mod.rs, src/openhuman/tools/ops.rs, src/openhuman/flows/tools_tests.rs
Declares/exports the tools module, registers ProposeWorkflowTool in the tool registry, and adds tests for validation, summary content, and tool metadata.

Frontend workflow proposal UI

Layer / File(s) Summary
Redux state and reducers
app/src/store/chatRuntimeSlice.ts
Adds WorkflowProposal/WorkflowProposalStep types, pendingWorkflowProposalsByThread state, set/clear reducers, and cleanup on reset/hydration.
Tool result parsing
app/src/providers/ChatRuntimeProvider.tsx, app/src/utils/toolTimelineFormatting.ts
Parses propose_workflow tool output into a WorkflowProposal, dispatches it into runtime state, and adds a display label for the tool.
createFlow API
app/src/services/api/flowsApi.ts
Adds createFlow calling the flows_create RPC and wires it into flowsApi.
WorkflowProposalCard component and tests
app/src/components/chat/WorkflowProposalCard.tsx, WorkflowProposalCard.test.tsx
New component with save/dismiss actions, loading/error states, step rendering, and a full test suite.
Conversations page integration
app/src/pages/Conversations.tsx
Selects and derives the pending proposal for the active thread and conditionally renders the card.
Localized strings
app/src/lib/i18n/*.ts
Adds chat.flowProposal.* translation keys across all supported locales.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Agent
  participant ProposeWorkflowTool
  participant ChatRuntimeProvider
  participant ReduxStore
  participant WorkflowProposalCard
  participant createFlow

  Agent->>ProposeWorkflowTool: propose_workflow(name, graph, require_approval)
  ProposeWorkflowTool-->>Agent: workflow_proposal JSON
  ChatRuntimeProvider->>ChatRuntimeProvider: parseWorkflowProposal(output)
  ChatRuntimeProvider->>ReduxStore: dispatch setWorkflowProposalForThread
  ReduxStore-->>WorkflowProposalCard: pendingWorkflowProposal
  WorkflowProposalCard->>WorkflowProposalCard: render trigger/steps
  WorkflowProposalCard->>createFlow: createFlow(name, graph, requireApproval) [on Save]
  createFlow-->>WorkflowProposalCard: Flow or error
  WorkflowProposalCard->>ReduxStore: dispatch clearWorkflowProposalForThread
Loading

Possibly related PRs

  • tinyhumansai/openhuman#4430: Both PRs extend the shared tool registry/export plumbing in openhuman/tools/mod.rs and openhuman/tools/ops.rs.
  • tinyhumansai/openhuman#4433: Both PRs build on the same src/openhuman/flows engine seam, including mod.rs and ops.rs validation/migration path.

Suggested labels: feature, agent, rust-core

Suggested reviewers: M3gA-Mind

Poem

A carrot-shaped graph, a trigger, a hop,
The agent proposes — nothing's saved 'til we stop.
Steps in a list, badges all neat,
"Save & enable" makes the flow complete! 🐇
Ten tongues now speak of proposals anew,
Dismiss or approve — the choice, rabbit, is you.


Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c9a944528

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// action ever calls `flows_create`, so this dispatch alone can never
// create a flow.
if (event.tool_name === 'propose_workflow' && event.success) {
const proposal = parseWorkflowProposal(event.output);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Wire workflow proposals from actual tool output

In the normal web-chat path, tool_result events do not contain the tool's returned body: progress_bridge.rs publishes output as only {"output_chars":...,"elapsed_ms":...} for AgentProgress::ToolCallCompleted. Therefore a successful propose_workflow call will parse that placeholder here, fail the type === 'workflow_proposal' check, and never dispatch setWorkflowProposalForThread, so the Save/Dismiss card is never shown. Please either include this tool's actual result in the socket event or source the proposal from another captured outcome.

Useful? React with 👍 / 👎.

setSaving(true);
setErrorMsg(null);
try {
await createFlow(proposal.name, proposal.graph, proposal.requireApproval);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Force approval on agent-proposed flows

When the agent includes require_approval: false, the parser stores requireApproval: false and this save path forwards it unchanged to flows_create. The approval gate treats workflow runs with require_approval: false as trusted and allows predeclared external actions without prompting, while the card only shows a message when approval is true. A prompt-injected proposal can therefore become an enabled flow whose future outbound tool/HTTP steps skip HITL after a generic Save click; force agent-authored proposals to true or make the no-approval state explicit and separately confirmed.

Useful? React with 👍 / 👎.

…card)

Talk → workflow. A new propose_workflow agent tool lets the assistant draft a
WorkflowGraph; it VALIDATES the graph (validate_and_migrate_graph, the same path
flows_create uses) and returns a summary — it never persists. The chat renders a
WorkflowProposalCard; the user's Save (and only that) calls flows_create.

Backend: flows/tools.rs ProposeWorkflowTool (permission None, external_effect
false; validate-or-error so the agent self-corrects) + tools_tests.rs (15);
validate_and_migrate_graph made pub(crate); registered in tools/ops.rs.
Frontend: WorkflowProposalCard.tsx (+test); flowsApi.createFlow + Flow type;
chatRuntimeSlice pendingWorkflowProposalsByThread + reducers; ChatRuntimeProvider
onToolResult → dispatch when tool_name==propose_workflow (persists past turn-end);
Conversations.tsx renders it; toolTimelineFormatting label; i18n chat.flowProposal.*
x14 locales (distinct namespace, no B3b/B5a conflict).

Human-in-the-loop invariant: no agent/tool path reaches flows_create.
Rust: 15 tool + 271 flows tests pass, tool live in registry. Frontend: typecheck/
lint/prettier clean, card 8 + runtime 157 tests pass, i18n parity clean.
@graycyrus graycyrus force-pushed the feat/flows-b4-agent-proposal branch from 1c9a944 to d5b2fe9 Compare July 3, 2026 20:24
@graycyrus graycyrus merged commit 1de7506 into tinyhumansai:main Jul 3, 2026
5 of 6 checks passed
@coderabbitai coderabbitai Bot added agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. feature Net-new user-facing capability or product behavior. rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. labels Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Built-in agents, prompts, orchestration, and agent runtime in src/openhuman/agent/. feature Net-new user-facing capability or product behavior. rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant