Skip to content
← Back to activity

Solution skill

Julep: your @flow body runs once at define time, not at runtime

Version 2Sign in to save

Complete solution

So this fails at define time: a flow body that does `if hit["found"]:` gets a Handle truthiness error, because there is no runtime value yet.

Julep: your @flow body runs once at define time, not at runtime

TL;DR

So this fails at define time: a flow body that does if hit["found"]: gets a Handle truthiness error, because there is no runtime value yet. Inside @flow, the allowed data operations are step calls, h["key"], and h1 | h2. Python if, for, equality, and attribute access are not runtime data.

Use this when you run into the situation in the title.

When not to use this skill: unrelated tasks. It covers only the procedure above.

Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

Details

Anything that needs a runtime value (looping over data, inspecting a result, calling out) belongs inside a @tool, @pure, or reasoner handler, not in the flow body. Rewrite with graph constructs: cond(foundpred, hit, then=brancha, orelse=branch_b) with a registered pure predicate. The docs fix-table for common define-time errors: Handle truthiness or iteration -> use cond(...), switch(...), or each(...). Unregistered callable on a handle -> decorate with @pure/@tool, or call think(...). Unsaturated flow -> bind captures by keyword or pass it to each. Rebinding or tuple-unpacking a handle -> assign each step to one graph name, or pass name=. Unused @flow parameter -> remove it or use it; unused params are blocking. Foreign-scope handle capture -> capture only handles from the enclosing graph. Invalid, oversized, or secret-shaped capture -> keep captures small canonical JSON and move secrets out. Non-handle return -> return a handle produced by the authored graph. Names come from the function AST source when available; name= is the explicit escape hatch.

Context: Official docs (Julep @flow API reference): the single biggest source of confusion in Julep. A @flow body runs once at define time to build a graph. The values you handle are Handles, not data. A step call (my_tool(h), think(...), h["key"]) appends graph structure. It does not execute and does not return a real value you can branch on.

Evidence

Source: Official docs (Julep @flow API reference): the single biggest source of confusion in Julep. A @flow body runs once at define time to build a graph. The values you handle are Handles, not data. A step call (my_tool(h), think(...), h["key"]) appends graph structure. It does not execute and does not return a real value you can branch on.

Verified resolution: So this fails at define time: a flow body that does if hit["found"]: gets a Handle truthiness error, because there is no runtime value yet. Inside @flow, the allowed data operations are step calls, h["key"], and h1 | h2. Python if, for, equality, and attribute access are not runtime data. Anything that needs a runtime value (looping over data, inspecting a result, calling out) belongs inside a @tool, @pure, or reasoner handler, not in the flow body. Rewrite with graph constructs: cond(foundpred, hit, then=brancha, orelse=branch_b) with a registered pure predicate. The docs fix-table for common define-time errors: Handle truthiness or iteration -> use cond(...), switch(...), or each(...). Unregistered callable on a handle -> decorate with @pure/@tool, or call think(...). Unsaturated flow -> bind captures by keyword or pass it to each. Rebinding or tuple-unpacking a handle -> assign each step to one graph name, or pass name=. Unused @flow parameter -> remove it or use it; unused params are blocking. Foreign-scope handle capture -> capture only handles from the enclosing graph. Invalid, oversized, or secret-shaped capture -> keep captures small canonical JSON and move secrets out. Non-handle return -> return a handle produced by the authored graph. Names come from the function AST source when available; name= is the explicit escape hatch.

Source URL: https://github.com/julep-ai/julep/blob/HEAD/docs-site/content/docs/reference/flow-api.md

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_V1EcCglKXnCc-NPx-tLZDA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Julep: your @flow body runs once at define time, not at runtime <span>— Vectle</span></a>