Results
BindAI usesAgentResult as the primary result object for completed agent execution.
The result abstraction keeps application code independent from provider-specific response objects and provides a consistent way to access:
- Execution status
- Generated output
- Execution error information when a failed result is returned
AgentResult.
AgentResult
A completed agent execution returns anAgentResult.
For example:
error is normally None.
Accessing the Output
The generated response is available throughresult.output.
output therefore depends on how the agent was executed.
Checking Execution Status
Useresult.success when application behavior depends on whether execution completed successfully.
AgentResult has:
AgentResult. Some execution paths can raise Python exceptions instead.
Structured Output
BindAI supports structured output through theoutput parameter of run().
For example:
result.output contains the constructed output object.
For example:
Structured Output Processing
The execution layer processes structured output after receiving the model response. The current execution path:- Gets the model response text.
- Parses the response as JSON.
- Passes the resulting dictionary to the requested output type.
- Returns the constructed object when conversion succeeds.
- Falls back to the raw response text when conversion fails.
Structured Output Fallback
Structured-output conversion does not guarantee that the final output will always be an instance of the requested type. If JSON parsing or output construction fails, the execution layer falls back to the original response text. Therefore, applications should consider checking the output type when the distinction matters:Inspecting Result Information
During development, inspect the result object directly:Handling Execution Failures
Agent execution can encounter failures such as:- Missing provider configuration
- Invalid credentials
- Unsupported model configuration
- Network failures
- Provider errors
- Tool execution failures
- Maximum tool iteration failures
- Other execution errors
AgentResult and a Python exception.
A failed result can be handled with:
Results and Exceptions
AgentResult and Python exceptions represent different execution outcomes.
A result represents an execution path that returned an AgentResult.
An exception interrupts normal execution and is handled through Python exception handling.
For example:
Tool Results
Tool results are separate from the finalAgentResult.
A tool can return an ordinary Python value:
Tool Execution Failures
Tool failures can affect the overall agent execution. For example, the execution layer can receive a tool result containing an error and pass that information back into the model execution flow. Applications should therefore distinguish between:- The value returned by an individual tool.
- The model response generated after tool execution.
- The final
AgentResultreturned by the agent.
Maximum Tool Iterations
Agent execution can perform multiple model/tool turns. The agent configuration includes:Workflow Results
Workflow execution has its own result and data flow. Workflow nodes can produce values that are passed to later nodes, and a workflow can expose its own execution result. For example:AgentResult.
In particular:
Result Flow
The general completed-agent result flow is:Results and Structured Applications
Structured results are useful when agent output is consumed directly by application code. For example:Results from Streaming
Streaming execution differs from standardrun() execution.
For example:
AgentResult.
The streaming execution path calls the provider’s stream() method.
Conceptually:
run() when the application needs a completed AgentResult.
Use streaming when the application needs to process or display model output progressively.
Result Handling in Applications
A typical application can handle a completed result like this:Keeping Provider Responses Out of Application Code
One purpose ofAgentResult is to provide a common application-facing result abstraction.
Instead of depending directly on provider SDK response objects:
Debugging Results
When debugging an agent execution, inspect the result type and values:Result Handling Best Practices
- Use
result.outputto access completed agent output. - Check
result.successwhen application behavior depends on successful execution. - Inspect
result.errorwhen a failed result is returned. - Handle Python exceptions separately.
- Use structured output when downstream code requires predictable Python objects.
- Do not assume structured conversion always succeeds.
- Treat tool results separately from the final
AgentResult. - Treat workflow results according to the workflow API.
- Use streaming when incremental output is required.
- Use
run()when the application needs a completed result. - Keep provider-specific response handling out of application code.
- Verify result types when supporting multiple BindAI versions or output types.
- Test result handling against the BindAI version used by the application.
Summary
AgentResult is the primary result abstraction for completed BindAI agent execution.
Its public fields are:
output can contain the constructed output object when JSON parsing and output-type construction succeed. If structured conversion fails in the current execution path, BindAI falls back to the raw response.
A failed AgentResult can expose an error through:
AgentResult.
Streaming is a separate execution mode and returns incremental provider output rather than a completed AgentResult.
By using AgentResult instead of provider-specific response objects, applications can keep result handling consistent across supported model providers.