Skip to content

Commit

Permalink
Merge pull request #1185 from julep-ai/f/enable-recursion
Browse files Browse the repository at this point in the history
feat(agents-api): enable self recursion
  • Loading branch information
Ahmad-mtos authored Feb 25, 2025
2 parents 17b06bb + 1c06908 commit 746cfbf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def validate_transition_targets(data: CreateTransitionRequest) -> None:
case "resume" | "step":
assert data.next is not None, "Next target must be provided for resume/step"

if data.next.workflow == data.current.workflow:
if data.next.scope_id == data.current.scope_id:
assert data.next.step > data.current.step, (
"Next step must be greater than current"
)
Expand Down
45 changes: 45 additions & 0 deletions agents-api/tests/test_execution_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,51 @@ async def _(dsn=pg_dsn, developer_id=test_developer_id, execution=test_execution
assert result.output == {"result": "test"}


@test("query: create execution transition - validate transition targets")
async def _(dsn=pg_dsn, developer_id=test_developer_id, execution=test_execution):
pool = await create_db_pool(dsn=dsn)
scope_id = uuid7()
await create_execution_transition(
developer_id=developer_id,
execution_id=execution.id,
data=CreateTransitionRequest(
type="init_branch",
output={"result": "test"},
current={"workflow": "subworkflow", "step": 0, "scope_id": scope_id},
next={"workflow": "subworkflow", "step": 0, "scope_id": scope_id},
),
connection_pool=pool,
)

await create_execution_transition(
developer_id=developer_id,
execution_id=execution.id,
data=CreateTransitionRequest(
type="step",
output={"result": "test"},
current={"workflow": "subworkflow", "step": 0, "scope_id": scope_id},
next={"workflow": "subworkflow", "step": 1, "scope_id": scope_id},
),
connection_pool=pool,
)

result = await create_execution_transition(
developer_id=developer_id,
execution_id=execution.id,
data=CreateTransitionRequest(
type="step",
output={"result": "test"},
current={"workflow": "subworkflow", "step": 1, "scope_id": scope_id},
next={"workflow": "subworkflow", "step": 0, "scope_id": uuid7()},
),
connection_pool=pool,
)

assert result is not None
assert result.type == "step"
assert result.output == {"result": "test"}


@test("query: create execution transition with execution update")
async def _(
dsn=pg_dsn,
Expand Down

0 comments on commit 746cfbf

Please sign in to comment.