<#1306 feat(agents): use flyte-native conditions f...
# flyte-github
a
#1306 feat(agents): use flyte-native conditions for HITL tool approval Pull request opened by cosmicBboy Summary Migrates the
flyte.ai.agents
human-in-the-loop approval flow off the
flyteplugins-hitl
plugin and onto the flyte-native Condition API (
flyte.new_condition
). •
src/flyte/ai/agents/agent.py
— the default
approval_callback
(
_condition_approval
, formerly
_hitl_approval
) now registers a run-scoped bool condition with a markdown prompt showing the tool name and JSON arguments, then blocks on
condition.wait()
until a human signals it — from the UI, the CLI (
flyte signal condition <run> <action> true
), or
flyte.remote.Condition.signal
. Outside a task context (no backend to signal the condition) it logs a warning and denies, mirroring the old plugin-missing fallback so the agent can recover by trying a different approach. •
examples/agents/flyte_agent/hitl_approval_agent.py
— drops the
flyteplugins-hitl
dependency,
depends_on=[hitl.env]
, and the `fastapi`/`uvicorn`/`python-multipart` packages that existed only for the plugin's web form; the
__main__
block now shows how to signal the pending approval condition programmatically. •
examples/agents/flyte_agent/README.md
— updated HITL references to
flyte.new_condition
. •
tests/flyte/ai/agents/test_agent.py
— replaced the plugin-missing test with
TestDefaultConditionApproval
, covering deny-outside-task-context, approve, and decline paths (asserting condition name,
data_type=bool
, markdown prompt type, and args in the prompt). Notes: • The task-context check uses truthiness (
if not flyte.ctx()
) rather than
is None
, so it remains correct if/when
flyte.ctx()
returns a falsy null object instead of
None
. •
examples/genai/autoresearch/autoresearch_agent.py
still uses
flyteplugins.hitl
directly for its loop-continuation gate; that's independent of the agent harness and left for a follow-up. Test plan •
uv run pytest tests/flyte/ai/agents/test_agent.py
— 178 passed •
uv run ruff check
/
ruff format --check
on changed files •
uv run mypy src/flyte/ai/agents/agent.py
•
py_compile
on the updated example 🤖 Generated with Claude Code flyteorg/flyte-sdk