Skip to content

Instantly share code, notes, and snippets.

@Janiczek
Last active February 23, 2026 18:11
Show Gist options
  • Select an option

  • Save Janiczek/270f9ce142d626c7b4f70728c1083c44 to your computer and use it in GitHub Desktop.

Select an option

Save Janiczek/270f9ce142d626c7b4f70728c1083c44 to your computer and use it in GitHub Desktop.
Imagined example of "agents as part of deterministic workflows"
from agentflow import flow, agent, StepFailure, FlowAbort
from agentflow.integrations.jira import fetch_issue, JiraIssue
elm_make = agentflow.run("elm make --optimize src/Main.elm")
elm_test = agentflow.run("elm-test")
elm_review = agentflow.run("elm-review")
elm_format = agentflow.run("elm-format -y src/**/*.elm")
@flow(max_retries=3)
def fix_bug(jira_key: str):
issue: JiraIssue = fetch_issue(jira_key)
# 1. Is it green?
try:
elm_test()
except StepFailure as e:
raise FlowAbort( # no retries! user has to fix this
f"""
Test suite not green, can't start fix_bug workflow:
{e.output}
"""
)
# 2. Write a regression test
agent(
f"""
A bug has been reported in {jira_key}: {issue.summary}
{issue.description}
Write a regression test that reproduces this bug
(it must FAIL with current code).
Do not fix the bug yet.
""",
context=["docs/CONVENTIONS.md"],
post_checks=[elm_make],
can_write=["tests/**/*.elm"],
)
# 3. Is it red?
failure_output = elm_test.expect_fail(
"""Added regression test should have failed
(reproduced the bug) but the test suite passed."""
)
# 4. Fix the bug
agent(
f"""
Fix the bug reported in {jira_key}: {issue.summary}
{issue.description}
The regression test is now failing as expected:
{failure_output}
Fix the source code so all tests pass. Do not modify the test file.
""",
context=[
"docs/CONVENTIONS.md",
agentflow.git_diff,
],
post_checks=[elm_make],
can_write=["src/**/*.elm"],
)
# 5. Is it green?
elm_test()
elm_review()
elm_format()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment