Agently Agent Docs
This page is for Claude Code, Codex, and other coding agents. It provides core primitives, recommended patterns, and runnable templates for building reliable AI apps with Agently.
Goals and boundaries
- Goal: implement stable, maintainable, and orchestrated AI application code.
- Boundary: Agently is a framework layer; ops/evals can be integrated separately.
Core objects
- Agent: high-level entry point for prompt, output control, and tools.
- Request: configuration and execution for a single call.
- ModelResponse: response snapshot with reusable results.
- Output Format: structured output constraints.
- TriggerFlow: event-driven orchestration.
Standard workflow
- Configure model (OpenAICompatible).
- Design layered prompts (agent/request).
- Define Output Format for stable structure.
- Call
get_response()once, then read results. - Use TriggerFlow for multi-step orchestration.
Key patterns and templates
1) Structured output (stable results)
python
from agently import Agently
agent = Agently.create_agent()
result = (
agent
.input("Write a release plan with goals and milestones")
.output({
"goal": ("str", "Goal"),
"milestones": [
{"title": ("str", "Milestone"), "date": ("str", "Date")}
]
})
.start()
)
print(result)2) One request, multi-read
python
from agently import Agently
agent = Agently.create_agent()
response = (
agent
.input("Introduce Agently in one sentence")
.output({"intro": ("str", "One line")})
.get_response()
)
print(response.get_text())
print(response.get_data())
print(response.get_meta())3) Instant streaming structured output
python
from agently import Agently
agent = Agently.create_agent()
response = (
agent
.input("Explain recursion in one sentence and add 2 tips")
.output({
"definition": ("str", "Short definition"),
"tips": [("str", "Short tip")]
})
.get_response()
)
for msg in response.get_generator(type="instant"):
if msg.path == "definition" and msg.delta:
print(msg.delta, end="", flush=True)
if msg.wildcard_path == "tips[*]" and msg.delta:
print(msg.delta, end="", flush=True)
print()4) Layered prompts (context governance)
python
from agently import Agently
agent = Agently.create_agent()
agent.set_agent_prompt("system", "You are an enterprise knowledge assistant")
agent.set_agent_prompt("instruct", ["Keep answers concise and actionable"])
print(
agent
.set_request_prompt("input", "Give one deployment recommendation")
.output({"advice": ("str", "One line")})
.start()
)5) TriggerFlow orchestration
python
from agently import TriggerFlow, TriggerFlowEventData
flow = TriggerFlow()
@flow.chunk
async def normalize(data: TriggerFlowEventData):
return str(data.value).strip().lower()
@flow.chunk
async def greet(data: TriggerFlowEventData):
return f"hi {data.value}"
flow.to(normalize).to(greet).end()
print(flow.start(" Agently "))Anti-patterns
- Repeated
get_text()/get_data()on the chain triggers multiple requests. - Complex flows without TriggerFlow become hard to maintain.
- Packing all context into a request instead of reusing agent-level prompts.
Agent checklist
- Model settings configured (OpenAICompatible).
- Output structured; use
ensure_keyswhen needed. - Use
get_response()to pin a single request. - TriggerFlow for multi-step orchestration.
- Streaming via
get_generator(...)/get_async_generator(...).