Results
BindAI returns result objects from agent execution instead of exposing provider-specific response objects directly. The result gives applications a consistent way to access generated output and execution information.AgentResult
Callingagent.run() returns an AgentResult.
AgentResult is the primary result type returned by BindAI agent execution.
You can inspect the result during development:
Accessing the Output
The generated response is available throughresult.output.
output contains the generated response.
When structured output is requested, output contains the resulting Python object.
Checking Execution Status
AgentResult exposes a success status that can be used to determine whether the execution completed successfully.
AgentResult.
Structured Output
BindAI supports structured output through theoutput parameter of run().
For example, a Pydantic model can define the expected result:
output can be a validated Person instance rather than requiring manual JSON parsing.
Provider and model capabilities should be verified when relying on structured output.
Inspecting Result Information
During development, inspect the result object directly:AgentResult type:
Handling Execution Failures
Agent execution can fail for different reasons, including:- Provider configuration problems
- Authentication failures
- Invalid model configuration
- Network failures
- Tool execution failures
- Provider service errors
- Other execution errors
AgentResult field.
For operations that can raise exceptions, handle them explicitly:
AgentResult, the application can inspect its status:
Results and Exceptions
Result objects and Python exceptions serve different purposes. A result represents an operation that completed and returned anAgentResult.
An exception represents a failure that interrupts normal execution.
For example:
AgentResult.
Tool Results
Tool results are separate fromAgentResult.
A tool can return ordinary Python values:
AgentResult.
For advanced tool execution and result handling, use the BindAI Tool API.
Workflow Results
Workflows have their own execution model and result handling. A workflow can produce values that are passed between workflow nodes and eventually exposed as workflow output. For example:AgentResult.
Result Flow
The general agent execution model can be represented as:Results and Structured Applications
Structured results are particularly useful when agent output is consumed by application code. For example:Results from Streaming
Streaming execution differs from standardrun() execution.
For example:
AgentResult before displaying the response.
Use standard run() when the application needs the completed execution result.
Use streaming when the application needs to process or display output progressively.
Debugging Results
During development, inspect the complete result and its type:Keeping Provider Responses Out of Application Code
One purpose ofAgentResult is to prevent application code from depending directly on provider SDK response objects.
Instead of writing provider-specific response handling:
Result Handling in Applications
A typical application can handle an agent result like this:Result Handling Best Practices
- Use
result.outputto access generated agent output. - Check
result.successwhen application behavior depends on successful execution. - Use structured output when downstream code requires predictable Python objects.
- Inspect result types instead of assuming undocumented fields.
- Handle execution exceptions explicitly when failures need special treatment.
- Keep provider-specific response handling out of application code.
- Treat tool results separately from final agent results.
- Treat workflow results according to the workflow API rather than assuming they match
AgentResult. - Test result handling against the BindAI version used by the application.
- Verify provider support when relying on structured output or streaming.
Summary
AgentResult is the primary result abstraction returned by BindAI agent execution.
For standard text generation, access the generated response through result.output.
Use result.success and result.error when the application needs to handle unsuccessful results.
For structured generation, output can contain a validated Python object when supported by the configured provider and model.
Exceptions should be handled separately because not every execution failure necessarily produces an AgentResult.
By relying on the BindAI result abstraction rather than provider-specific response objects, applications can remain more portable across providers and models.