Skip to content

Compile-to-weights ⑥: invoke a compiled workflow as a stargraph call/function (graph-as-tool + alias) #170

Description

@se-jo-ma

Pipeline block ⑥ (Call as a function: invoke a compiled workflow). Part of the compile-to-weights epic. This is the "use a compiled workflow via a stargraph call/function" piece.

Context. A graph can be driven via CLI (cli/run.py), the Python API (Graph.start()GraphRun), and REST (serve/api.py POST /v1/runs:684). But there is no "graph as a callable function/tool" wrapper, and no turnkey "invoke the compiled version of workflow X by registry alias."

Proposal. Two thin surfaces:

  • graph-as-tool: new src/stargraph/tools/graph_invoke.py (model on tools/decorator.py) — a tool that takes graph_id + optional initial_state patch, runs Graph.start()GraphRun, returns final_state. Lets one graph call a compiled workflow as a tool.
  • invoke-by-alias: a thin path over the existing POST /v1/runs (serve/api.py:684, Scheduler.enqueue) + Python API that resolves the compiled-model production/staging alias (block ④ registry) for the graph, so callers invoke "the current compiled workflow" by name and the alias-flip swaps the served checkpoint underneath.

Acceptance criteria.

  • graph_invoke tool runs a named graph and returns its final state as tool output.
  • A caller can invoke a compiled workflow by id/alias via Python + REST; flipping the registry alias swaps the served model with no caller change.
  • Invocation records which compiled (model_id, version) served the run, for audit.

Depends on block ⑤ (CompiledWorkflowNode) and block ④ (registry runtime).


Source: arXiv:2605.22502v1 — "Compiling Agentic Workflows into LLM Weights" (subterranean agents). Part of the end-to-end compile-to-weights pipeline epic; file refs verified against current main. Determinism: per-graph knob (fully-compiled | hybrid | rules-only) defaults to honor #117 (no learned core router).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority: roadmap gap or DX/toolingarea/serveharbor serve FastAPI daemonenhancementNew feature or requestsize/M<2 days: multi-file feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions