AI Infra in Graphics: take control flow away from the model
In a deterministic graph process engine, the business logic is an explicit graph. Application code handles the state, the parallel workers, the saves and the retries. The model is called only as a bounded step that has to return a typed result.
By Anthony Skinner, CEO and Co-Founder, and the Pressfit.ai Engineering Team
A compiled state machine handles every route.
No tokens spent on ingestion, math or routing.
Typed JSON state saved after every step.
Code gates send low scores to a person.
The vendor audit graph, step by step
This is the reference graph from our starter kit. Click any step to see its contract, or run the graph and watch the shared WorkflowState change as it moves through code steps and the one model step.
Pydantic checks vendor_id and vendor_docs before the graph starts.
Plain Python strips whitespace and sets retry_count=0.
Each isolated call must return a VerificationResult JSON schema.
if compliance_passed and audit_score >= 0.85:
Commits the approval and ends the run.
Pauses the state and alerts the team.
Sanitize the data and set the state
Plain Python cleans the inputs and sets the starting state.
An example run. Token and timing figures are illustrative.
Tokens and state, graph engine vs prompt agent
How compute and state memory behave in a deterministic graph engine compared with an unconstrained prompt agent across a multi-step workflow.
Tokens by step role
Most workflow steps need no generated tokens once they are written as code steps.
Takeaway: Keeping model calls to the semantic_audit_node stops token spend on ingestion, routing and report assembly.
Context size across the workflow
Typed state stays flat. An unconstrained chat history keeps growing with every step.
Takeaway: A bounded state schema keeps the context window from filling up and the run from drifting, even at 100+ steps.
Illustrative figures from the reference architecture, not measured test results. For measured results, see our research.
The design rules
To build this in production with LangGraph, Temporal or your own state machine, hold your codebase to these four boundaries.
Typed state, not chat history
Never pass raw message threads between steps. Define the state as a Pydantic or TypeScript schema, and pin business rules like approval thresholds as read-only values.
Structured output from every model step
Every model step must pass JSON schema validation before it hands control back to the graph. If it returns malformed JSON, a code retry catches it right away.
Routing in code, never in a prompt
Never ask a model which step comes next. Check scores, flags and thresholds with plain if/else edges in your code.
Save the state at every step
Checkpoint the state to Redis or Postgres on every edge. If an API times out or an approval waits two days, the run picks up where it stopped without losing tokens.
Build it yourself, or have us build it
Start with the Graph Workflow Starter Kit, or work with our dev team and Red Dev Test team to turn your skills into a tested, deterministic path.