Autonomous Agent
Autonomous Agents
Autonomous agents represent a significant advancement in AI system design, combining the power of language models with the ability to perform tasks autonomously. This tutorial will guide you through building an autonomous agent using Synalinks, capable of processing mathematical queries and returning numerical answers.
Understanding the Foundation
Autonomous agents address a fundamental limitation of traditional systems by enabling them to perform tasks without constant human intervention. While language models excel at generating coherent text, they often require additional tools and logic to perform specific tasks autonomously. Autonomous agents bridge this gap by dynamically processing information and executing tasks based on predefined tools.
The architecture of an autonomous agent follows several core stages:
- The input stage captures the user's query or command.
- The processing stage uses predefined tools and logic to process the input and generate a response.
- The output stage returns the result to the user.
graph LR
A[Query] --> B[Agent]
B --> C{Need Tool?}
C -->|Yes| D[Tool Call]
D --> E[Tool Result]
E --> B
C -->|No| F[Final Answer]
Synalinks streamlines this complex process through its modular architecture, allowing you to compose components with precision while maintaining flexibility for different use cases.
Creating an Autonomous Agent
Define tools as async functions with complete docstrings, then wrap them with synalinks.Tool:
@synalinks.utils.register_synalinks_serializable()
async def calculate(expression: str):
"""Calculate the result of a mathematical expression.
Args:
expression (str): The mathematical expression to calculate.
"""
result = eval(expression)
return {"result": result, "log": "Successfully executed"}
tools = [synalinks.Tool(calculate)]
Important Tool Constraints:
-
No Optional Parameters: All parameters must be required. LLM providers require all tool parameters to be required in JSON schemas.
-
Complete Docstring Required: Every parameter must have a description in the
Args:section of the docstring. The Tool uses these to build the JSON schema sent to the LLM.
Create the agent with FunctionCallingAgent in autonomous mode:
inputs = synalinks.Input(data_model=Query)
outputs = await synalinks.FunctionCallingAgent(
data_model=NumericalFinalAnswer,
tools=tools,
language_model=language_model,
max_iterations=5,
return_inputs_with_trajectory=True,
autonomous=True, # Agent runs until completion
)(inputs)
Key Takeaways
- Autonomous Task Execution: Autonomous agents solve the fundamental problem of performing tasks without constant human intervention.
- Synalinks Modular Implementation: The framework simplifies the development
of autonomous agents through composable components like
FunctionCallingAgent. - Explicit Data Model Contracts: Using structured
Queryand output models ensures type safety and predictable behavior. - Tool Integration: Integrate tools like the calculate function into your autonomous agent for processing specific types of queries.
- Dynamic Processing: Autonomous agents dynamically process information and execute tasks based on predefined tools and logic.
Program Visualization
API References
calculate(expression)
async
Calculate the result of a mathematical expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression
|
str
|
The mathematical expression to calculate, such as '2 + 2'. The expression can contain numbers, operators (+, -, *, /), parentheses, and spaces. |
required |
Source code in examples/10_autonomous_agent.py
Source
import asyncio
from dotenv import load_dotenv
import synalinks
synalinks.enable_logging()
# Define the data models
class Query(synalinks.DataModel):
query: str = synalinks.Field(
description="The user query",
)
class NumericalFinalAnswer(synalinks.DataModel):
final_answer: float = synalinks.Field(
description="The correct final numerical answer",
)
# Define the calculation tool
@synalinks.utils.register_synalinks_serializable()
async def calculate(expression: str):
"""Calculate the result of a mathematical expression.
Args:
expression (str): The mathematical expression to calculate, such as
'2 + 2'. The expression can contain numbers, operators (+, -, *, /),
parentheses, and spaces.
"""
if not all(char in "0123456789+-*/(). " for char in expression):
return {
"result": None,
"log": (
"Error: invalid characters in expression. "
"The expression can only contain numbers, operators (+, -, *, /),"
" parentheses, and spaces NOT letters."
),
}
try:
# Evaluate the mathematical expression safely
result = round(float(eval(expression, {"__builtins__": None}, {})), 2)
return {
"result": result,
"log": "Successfully executed",
}
except Exception as e:
return {
"result": None,
"log": f"Error: {e}",
}
async def main():
load_dotenv()
# Enable observability for tracing
# synalinks.enable_observability(
# tracking_uri="http://localhost:5000",
# experiment_name="autonomous_math_agent",
# )
# Initialize the language model
language_model = synalinks.LanguageModel(
model="ollama/qwen3:8b",
)
# Define the tools available to the agent
tools = [
synalinks.Tool(calculate),
]
# ==========================================================================
# Create the autonomous agent
# ==========================================================================
print("Creating the autonomous agent...")
inputs = synalinks.Input(data_model=Query)
outputs = await synalinks.FunctionCallingAgent(
data_model=NumericalFinalAnswer,
tools=tools,
language_model=language_model,
max_iterations=5,
return_inputs_with_trajectory=True,
autonomous=True,
)(inputs)
agent = synalinks.Program(
inputs=inputs,
outputs=outputs,
name="math_agent",
description="A math agent",
)
synalinks.utils.plot_program(
agent,
to_folder="examples",
show_module_names=True,
show_trainable=True,
show_schemas=True,
)
# ==========================================================================
# Run the agent
# ==========================================================================
print("Running the agent...")
input_query = Query(query="How much is 152648 + 485?")
response = await agent(input_query)
print(response.prettify_json())
if __name__ == "__main__":
asyncio.run(main())
Run log
The log below is the unedited combined output of running the example above with local models (ollama).
Full run log — examples/10_autonomous_agent.log
(DEBUG) [Synalinks]
Call ID: 70b57dca-4117-4f36-9d84-3184b9d8fe78
Parent call ID: None
Module: FunctionCallingAgent
Module Name: function_calling_agent
Module Description: A trainable parallel function calling agent.
Data Model JSON Schema:
[
{
"additionalProperties": false,
"properties": {
"query": {
"description": "The user query",
"title": "Query",
"type": "string"
}
},
"required": [
"query"
],
"title": "Query",
"type": "object"
}
]
(DEBUG) [Synalinks]
Call ID: a6f1e953-b4a7-40e6-9921-de5e45e61f58
Parent call ID: 70b57dca-4117-4f36-9d84-3184b9d8fe78
Module: Generator
Module Name: tool_calls_generator_function_calling_agent
Module Description: Use a `LanguageModel` to generate a data model from an arbitrary input data model.
Data Model JSON Schema:
[
{
"additionalProperties": false,
"properties": {
"query": {
"description": "The user query",
"title": "Query",
"type": "string"
}
},
"required": [
"query"
],
"title": "Query",
"type": "object"
}
]
(DEBUG) [Synalinks]
Call ID: a6f1e953-b4a7-40e6-9921-de5e45e61f58
Parent call ID: 70b57dca-4117-4f36-9d84-3184b9d8fe78
Module: Generator
Module Name: tool_calls_generator_function_calling_agent
Module Description: Use a `LanguageModel` to generate a data model from an arbitrary input data model.
Data Model JSON Schema:
[
{
"$defs": {
"ChatRole": {
"description": "The chat message roles",
"enum": [
"system",
"developer",
"user",
"assistant",
"tool",
"function"
],
"title": "ChatRole",
"type": "string"
},
"ToolCall": {
"additionalProperties": false,
"description": "A tool call, shaped like an OpenAI Chat Completions tool call.\n\nMirrors the wire envelope (`{id, type, function: {name, arguments}}`)\nexcept that `arguments` stays a parsed dict rather than a JSON-encoded\nstring, so modules and agents can read it directly. The string encoding\nis applied only at the wire edge (see `backend.pydantic.chat_completions`).",
"properties": {
"id": {
"description": "The id of the tool call",
"title": "Id",
"type": "string"
},
"type": {
"const": "function",
"default": "function",
"description": "The tool call type (always `function` today)",
"title": "Type",
"type": "string"
},
"function": {
"$ref": "#/$defs/ToolCallFunction",
"description": "The function invocation (name + arguments)"
}
},
"required": [
"id",
"function"
],
"title": "ToolCall",
"type": "object"
},
"ToolCallFunction": {
"additionalProperties": false,
"description": "The `function` payload of a tool call (name + parsed arguments).",
"properties": {
"name": {
"description": "The name of the function called",
"title": "Name",
"type": "string"
},
"arguments": {
"additionalProperties": true,
"description": "The arguments of the tool call",
"title": "Arguments",
"type": "object"
}
},
"required": [
"name",
"arguments"
],
"title": "ToolCallFunction",
"type": "object"
}
},
"additionalProperties": false,
"description": "A chat message",
"properties": {
"role": {
"$ref": "#/$defs/ChatRole",
"description": "The chat message role"
},
"reasoning_content": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The reasoning/thinking content of the message. Keyed to match the litellm/DeepSeek `reasoning_content` chat-completion field (a provider extension, not part of the base OpenAI spec), so the message API stays a subset of the litellm-extended chat-completion message.",
"title": "Reasoning Content"
},
"thinking_blocks": {
"anyOf": [
{
"items": {
"additionalProperties": true,
"type": "object"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Opaque provider-native thinking blocks (e.g. Anthropic's signed `thinking_blocks`; a litellm extension, not part of the base OpenAI spec). Carried through verbatim on assistant-message re-injection so multi-turn tool-use round-trips preserve signatures. None for providers that emit reasoning only as text.",
"title": "Thinking Blocks"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"additionalProperties": true,
"type": "object"
},
"type": "array"
},
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"description": "The content of the message",
"title": "Content"
},
"tool_call_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The id of the tool call if role is `tool`",
"title": "Tool Call Id"
},
"tool_calls": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/ToolCall"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "The tool calls of the agent",
"title": "Tool Calls"
}
},
"required": [
"role"
],
"title": "ChatMessage",
"type": "object"
}
]
(DEBUG) [Synalinks]
Call ID: 170ad37b-e0d9-4051-9911-1611ab90dcdf
Parent call ID: a6f1e953-b4a7-40e6-9921-de5e45e61f58
Module: Generator
Module Name: tool_calls_generator_function_calling_agent
Module Description: Use a `LanguageModel` to generate a data model from an arbitrary input data model.
Data Model JSON Schema:
[
{
"additionalProperties": false,
"properties": {
"query": {
"description": "The user query",
"title": "Query",
"type": "string"
}
},
"required": [
"query"
],
"title": "Query",
"type": "object"
}
]
(DEBUG) [Synalinks]
Call ID: 170ad37b-e0d9-4051-9911-1611ab90dcdf
Parent call ID: a6f1e953-b4a7-40e6-9921-de5e45e61f58
Module: Generator
Module Name: tool_calls_generator_function_calling_agent
Module Description: Use a `LanguageModel` to generate a data model from an arbitrary input data model.
Data Model JSON Schema:
[
{
"$defs": {
"ChatRole": {
"description": "The chat message roles",
"enum": [
"system",
"developer",
"user",
"assistant",
"tool",
"function"
],
"title": "ChatRole",
"type": "string"
},
"ToolCall": {
"additionalProperties": false,
"description": "A tool call, shaped like an OpenAI Chat Completions tool call.\n\nMirrors the wire envelope (`{id, type, function: {name, arguments}}`)\nexcept that `arguments` stays a parsed dict rather than a JSON-encoded\nstring, so modules and agents can read it directly. The string encoding\nis applied only at the wire edge (see `backend.pydantic.chat_completions`).",
"properties": {
"id": {
"description": "The id of the tool call",
"title": "Id",
"type": "string"
},
"type": {
"const": "function",
"default": "function",
"description": "The tool call type (always `function` today)",
"title": "Type",
"type": "string"
},
"function": {
"$ref": "#/$defs/ToolCallFunction",
"description": "The function invocation (name + arguments)"
}
},
"required": [
"id",
"function"
],
"title": "ToolCall",
"type": "object"
},
"ToolCallFunction": {
"additionalProperties": false,
"description": "The `function` payload of a tool call (name + parsed arguments).",
"properties": {
"name": {
"description": "The name of the function called",
"title": "Name",
"type": "string"
},
"arguments": {
"additionalProperties": true,
"description": "The arguments of the tool call",
"title": "Arguments",
"type": "object"
}
},
"required": [
"name",
"arguments"
],
"title": "ToolCallFunction",
"type": "object"
}
},
"additionalProperties": false,
"description": "A chat message",
"properties": {
"role": {
"$ref": "#/$defs/ChatRole",
"description": "The chat message role"
},
"reasoning_content": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The reasoning/thinking content of the message. Keyed to match the litellm/DeepSeek `reasoning_content` chat-completion field (a provider extension, not part of the base OpenAI spec), so the message API stays a subset of the litellm-extended chat-completion message.",
"title": "Reasoning Content"
},
"thinking_blocks": {
"anyOf": [
{
"items": {
"additionalProperties": true,
"type": "object"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Opaque provider-native thinking blocks (e.g. Anthropic's signed `thinking_blocks`; a litellm extension, not part of the base OpenAI spec). Carried through verbatim on assistant-message re-injection so multi-turn tool-use round-trips preserve signatures. None for providers that emit reasoning only as text.",
"title": "Thinking Blocks"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"additionalProperties": true,
"type": "object"
},
"type": "array"
},
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"description": "The content of the message",
"title": "Content"
},
"tool_call_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The id of the tool call if role is `tool`",
"title": "Tool Call Id"
},
"tool_calls": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/ToolCall"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "The tool calls of the agent",
"title": "Tool Calls"
}
},
"required": [
"role"
],
"title": "ChatMessage",
"type": "object"
}
]
(DEBUG) [Synalinks]
Call ID: 70b57dca-4117-4f36-9d84-3184b9d8fe78
Parent call ID: None
Module: FunctionCallingAgent
Module Name: function_calling_agent
Module Description: A trainable parallel function calling agent.
Data Model JSON Schema:
[
{
"additionalProperties": false,
"$defs": {
"ChatMessage": {
"additionalProperties": false,
"description": "A chat message",
"properties": {
"role": {
"$ref": "#/$defs/ChatRole",
"description": "The chat message role"
},
"reasoning_content": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The reasoning/thinking content of the message. Keyed to match the litellm/DeepSeek `reasoning_content` chat-completion field (a provider extension, not part of the base OpenAI spec), so the message API stays a subset of the litellm-extended chat-completion message.",
"title": "Reasoning Content"
},
"thinking_blocks": {
"anyOf": [
{
"items": {
"additionalProperties": true,
"type": "object"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Opaque provider-native thinking blocks (e.g. Anthropic's signed `thinking_blocks`; a litellm extension, not part of the base OpenAI spec). Carried through verbatim on assistant-message re-injection so multi-turn tool-use round-trips preserve signatures. None for providers that emit reasoning only as text.",
"title": "Thinking Blocks"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"additionalProperties": true,
"type": "object"
},
"type": "array"
},
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"description": "The content of the message",
"title": "Content"
},
"tool_call_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The id of the tool call if role is `tool`",
"title": "Tool Call Id"
},
"tool_calls": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/ToolCall"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "The tool calls of the agent",
"title": "Tool Calls"
}
},
"required": [
"role"
],
"title": "ChatMessage",
"type": "object"
},
"ChatRole": {
"description": "The chat message roles",
"enum": [
"system",
"developer",
"user",
"assistant",
"tool",
"function"
],
"title": "ChatRole",
"type": "string"
},
"ToolCall": {
"additionalProperties": false,
"description": "A tool call, shaped like an OpenAI Chat Completions tool call.\n\nMirrors the wire envelope (`{id, type, function: {name, arguments}}`)\nexcept that `arguments` stays a parsed dict rather than a JSON-encoded\nstring, so modules and agents can read it directly. The string encoding\nis applied only at the wire edge (see `backend.pydantic.chat_completions`).",
"properties": {
"id": {
"description": "The id of the tool call",
"title": "Id",
"type": "string"
},
"type": {
"const": "function",
"default": "function",
"description": "The tool call type (always `function` today)",
"title": "Type",
"type": "string"
},
"function": {
"$ref": "#/$defs/ToolCallFunction",
"description": "The function invocation (name + arguments)"
}
},
"required": [
"id",
"function"
],
"title": "ToolCall",
"type": "object"
},
"ToolCallFunction": {
"additionalProperties": false,
"description": "The `function` payload of a tool call (name + parsed arguments).",
"properties": {
"name": {
"description": "The name of the function called",
"title": "Name",
"type": "string"
},
"arguments": {
"additionalProperties": true,
"description": "The arguments of the tool call",
"title": "Arguments",
"type": "object"
}
},
"required": [
"name",
"arguments"
],
"title": "ToolCallFunction",
"type": "object"
}
},
"properties": {
"messages": {
"default": [],
"description": "The list of chat messages",
"items": {
"$ref": "#/$defs/ChatMessage"
},
"title": "Messages",
"type": "array"
},
"final_answer": {
"description": "The correct final numerical answer",
"title": "Final Answer",
"type": "number"
}
},
"required": [
"final_answer"
],
"title": "ChatMessages",
"type": "object"
}
]
[Synalinks]
Call ID: 700303e8-f5b2-4537-a4cf-60e52284e4fb
Parent call ID: None
Module: Functional
Module Name: math_agent
Module Description: A math agent
Data Model JSON:
[
{
"query": "How much is 152648 + 485?"
}
]
[Synalinks]
Call ID: aa183ea2-9217-49c0-ba61-d0772042edc9
Parent call ID: 700303e8-f5b2-4537-a4cf-60e52284e4fb
Module: FunctionCallingAgent
Module Name: function_calling_agent
Module Description: A trainable parallel function calling agent.
Data Model JSON:
[
{
"query": "How much is 152648 + 485?"
}
]
[Synalinks]
Call ID: 1c6fa061-74c0-4113-94d0-9787edae7ac5
Parent call ID: aa183ea2-9217-49c0-ba61-d0772042edc9
Module: Generator
Module Name: tool_calls_generator_function_calling_agent
Module Description: Use a `LanguageModel` to generate a data model from an arbitrary input data model.
Data Model JSON:
[
{
"query": "How much is 152648 + 485?",
"messages": []
}
]
[Synalinks]
Call ID: dba546d2-9351-4dcb-8817-5b14f0d0cee0
Parent call ID: 1c6fa061-74c0-4113-94d0-9787edae7ac5
Module: LanguageModel
Module Name: language_model
Module Description: A language model API wrapper.
Data Model JSON:
[
{
"messages": [
{
"role": "system",
"content": "<instructions>\nThink step by step: Use the thinking field to elaborate what you observe and\nwhat do you need to accomplish next.\nReflect on prior steps: Review your previous actions and their outcomes to\navoid unnecessary repetition.\nAvoid unnecessary actions: If you already have enough information to complete\nthe user task, return an empty tool calls array.\n</instructions>\n"
},
{
"role": "user",
"content": "<input>\n{'query': 'How much is 152648 + 485?'}\n</input>\n<output>\n"
}
]
}
]
[Synalinks]
Call ID: dba546d2-9351-4dcb-8817-5b14f0d0cee0
Parent call ID: 1c6fa061-74c0-4113-94d0-9787edae7ac5
Module: LanguageModel
Module Name: language_model
Module Description: A language model API wrapper.
Data Model JSON:
[
{
"role": "assistant",
"content": "",
"reasoning_content": "Okay, the user is asking \"How much is 152648 + 485?\" So I need to calculate the sum of 152,648 and 485. Let me check if I have the right tools for this. The available function is 'calculate', which takes a mathematical expression as a string. The expression here is straightforward: adding two numbers. I should format the numbers correctly, making sure there are no typos. Let me verify the numbers again—152,648 and 485. Adding them together: 152,648 plus 400 is 153,048, then plus 85 more would be 153,133. Wait, but maybe I should just use the function to compute it accurately. The function can handle the addition, so I'll call 'calculate' with the expression \"152648 + 485\". That should give the correct result. No need for any other steps here since the function will handle the calculation.\n",
"tool_calls": [
{
"id": "call_hkwxl4ae",
"type": "function",
"function": {
"name": "calculate",
"arguments": {
"expression": "152648 + 485"
}
}
}
]
}
]
[Synalinks]
Call ID: 1c6fa061-74c0-4113-94d0-9787edae7ac5
Parent call ID: aa183ea2-9217-49c0-ba61-d0772042edc9
Module: Generator
Module Name: tool_calls_generator_function_calling_agent
Module Description: Use a `LanguageModel` to generate a data model from an arbitrary input data model.
Data Model JSON:
[
{
"role": "assistant",
"content": "",
"reasoning_content": "Okay, the user is asking \"How much is 152648 + 485?\" So I need to calculate the sum of 152,648 and 485. Let me check if I have the right tools for this. The available function is 'calculate', which takes a mathematical expression as a string. The expression here is straightforward: adding two numbers. I should format the numbers correctly, making sure there are no typos. Let me verify the numbers again—152,648 and 485. Adding them together: 152,648 plus 400 is 153,048, then plus 85 more would be 153,133. Wait, but maybe I should just use the function to compute it accurately. The function can handle the addition, so I'll call 'calculate' with the expression \"152648 + 485\". That should give the correct result. No need for any other steps here since the function will handle the calculation.\n",
"tool_calls": [
{
"id": "call_hkwxl4ae",
"type": "function",
"function": {
"name": "calculate",
"arguments": {
"expression": "152648 + 485"
}
}
}
]
}
]
[Synalinks]
Call ID: 0ddfcc52-d402-425d-a67e-9dcf9c473702
Parent call ID: dba546d2-9351-4dcb-8817-5b14f0d0cee0
Module: Tool
Module Name: calculate
Module Description: Calculate the result of a mathematical expression.
Keyword Arguments:
{
"expression": "152648 + 485"
}
[Synalinks]
Call ID: 0ddfcc52-d402-425d-a67e-9dcf9c473702
Parent call ID: dba546d2-9351-4dcb-8817-5b14f0d0cee0
Module: Tool
Module Name: calculate
Module Description: Calculate the result of a mathematical expression.
Data Model JSON:
[
{
"result": 153133.0,
"log": "Successfully executed"
}
]
[Synalinks]
Call ID: f53c4cd9-bca5-4d0e-a175-464974143ad8
Parent call ID: 0ddfcc52-d402-425d-a67e-9dcf9c473702
Module: Generator
Module Name: tool_calls_generator_function_calling_agent
Module Description: Use a `LanguageModel` to generate a data model from an arbitrary input data model.
Data Model JSON:
[
{
"query": "How much is 152648 + 485?",
"messages": [
{
"role": "assistant",
"content": "",
"reasoning_content": "Okay, the user is asking \"How much is 152648 + 485?\" So I need to calculate the sum of 152,648 and 485. Let me check if I have the right tools for this. The available function is 'calculate', which takes a mathematical expression as a string. The expression here is straightforward: adding two numbers. I should format the numbers correctly, making sure there are no typos. Let me verify the numbers again—152,648 and 485. Adding them together: 152,648 plus 400 is 153,048, then plus 85 more would be 153,133. Wait, but maybe I should just use the function to compute it accurately. The function can handle the addition, so I'll call 'calculate' with the expression \"152648 + 485\". That should give the correct result. No need for any other steps here since the function will handle the calculation.\n",
"tool_calls": [
{
"id": "call_hkwxl4ae",
"type": "function",
"function": {
"name": "calculate",
"arguments": {
"expression": "152648 + 485"
}
}
}
]
},
{
"role": "tool",
"content": {
"result": 153133.0,
"log": "Successfully executed"
},
"tool_call_id": "call_hkwxl4ae"
}
]
}
]
[Synalinks]
Call ID: 26f25409-dcfd-4c60-b9b6-c6ef040a39a5
Parent call ID: f53c4cd9-bca5-4d0e-a175-464974143ad8
Module: LanguageModel
Module Name: language_model
Module Description: A language model API wrapper.
Data Model JSON:
[
{
"messages": [
{
"role": "system",
"content": "<instructions>\nThink step by step: Use the thinking field to elaborate what you observe and\nwhat do you need to accomplish next.\nReflect on prior steps: Review your previous actions and their outcomes to\navoid unnecessary repetition.\nAvoid unnecessary actions: If you already have enough information to complete\nthe user task, return an empty tool calls array.\n</instructions>\n"
},
{
"role": "user",
"content": "<input>\n{'query': 'How much is 152648 + 485?'}\n</input>\n<output>\n"
},
{
"role": "assistant",
"reasoning_content": "Okay, the user is asking \"How much is 152648 + 485?\" So I need to calculate the sum of 152,648 and 485. Let me check if I have the right tools for this. The available function is 'calculate', which takes a mathematical expression as a string. The expression here is straightforward: adding two numbers. I should format the numbers correctly, making sure there are no typos. Let me verify the numbers again—152,648 and 485. Adding them together: 152,648 plus 400 is 153,048, then plus 85 more would be 153,133. Wait, but maybe I should just use the function to compute it accurately. The function can handle the addition, so I'll call 'calculate' with the expression \"152648 + 485\". That should give the correct result. No need for any other steps here since the function will handle the calculation.\n",
"content": "",
"tool_calls": [
{
"id": "call_hkwxl4ae",
"type": "function",
"function": {
"name": "calculate",
"arguments": {
"expression": "152648 + 485"
}
}
}
]
},
{
"role": "tool",
"content": {
"result": 153133.0,
"log": "Successfully executed"
},
"tool_call_id": "call_hkwxl4ae"
}
]
}
]
[Synalinks]
Call ID: 26f25409-dcfd-4c60-b9b6-c6ef040a39a5
Parent call ID: f53c4cd9-bca5-4d0e-a175-464974143ad8
Module: LanguageModel
Module Name: language_model
Module Description: A language model API wrapper.
Data Model JSON:
[
{
"role": "assistant",
"content": "The result of $152{,}648 + 485$ is **153{,}133**.",
"reasoning_content": "Okay, the user asked for the sum of 152,648 and 485. I used the calculate function with the expression \"152648 + 485\". The result came back as 153133.0. Let me check if that's correct. \n\nAdding 152,648 and 485:\n\nFirst, add the units place: 8 + 5 = 13. Carry over 1.\nThen the tens place: 4 + 8 = 12, plus the carried 1 makes 13. Carry over 1.\nHundreds place: 6 + 4 = 10, plus the carried 1 makes 11. Carry over 1.\nThousands place: 2 + 0 = 2, plus the carried 1 makes 3.\nTen-thousands place: 5 remains, and the 1 from the hundred-thousands place. So total is 153,133. \n\nThe calculation seems right. The function returned 153133.0, which matches my manual check. So the answer is correct. I should present it clearly to the user.\n"
}
]
[Synalinks]
Call ID: f53c4cd9-bca5-4d0e-a175-464974143ad8
Parent call ID: 0ddfcc52-d402-425d-a67e-9dcf9c473702
Module: Generator
Module Name: tool_calls_generator_function_calling_agent
Module Description: Use a `LanguageModel` to generate a data model from an arbitrary input data model.
Data Model JSON:
[
{
"role": "assistant",
"content": "The result of $152{,}648 + 485$ is **153{,}133**.",
"reasoning_content": "Okay, the user asked for the sum of 152,648 and 485. I used the calculate function with the expression \"152648 + 485\". The result came back as 153133.0. Let me check if that's correct. \n\nAdding 152,648 and 485:\n\nFirst, add the units place: 8 + 5 = 13. Carry over 1.\nThen the tens place: 4 + 8 = 12, plus the carried 1 makes 13. Carry over 1.\nHundreds place: 6 + 4 = 10, plus the carried 1 makes 11. Carry over 1.\nThousands place: 2 + 0 = 2, plus the carried 1 makes 3.\nTen-thousands place: 5 remains, and the 1 from the hundred-thousands place. So total is 153,133. \n\nThe calculation seems right. The function returned 153133.0, which matches my manual check. So the answer is correct. I should present it clearly to the user.\n"
}
]
[Synalinks]
Call ID: 4f610cad-74cb-404f-8f5d-dea1710a11a3
Parent call ID: 26f25409-dcfd-4c60-b9b6-c6ef040a39a5
Module: Generator
Module Name: final_generator_function_calling_agent
Module Description: Use a `LanguageModel` to generate a data model from an arbitrary input data model.
Data Model JSON:
[
{
"query": "How much is 152648 + 485?",
"messages": [
{
"role": "assistant",
"content": "",
"reasoning_content": "Okay, the user is asking \"How much is 152648 + 485?\" So I need to calculate the sum of 152,648 and 485. Let me check if I have the right tools for this. The available function is 'calculate', which takes a mathematical expression as a string. The expression here is straightforward: adding two numbers. I should format the numbers correctly, making sure there are no typos. Let me verify the numbers again—152,648 and 485. Adding them together: 152,648 plus 400 is 153,048, then plus 85 more would be 153,133. Wait, but maybe I should just use the function to compute it accurately. The function can handle the addition, so I'll call 'calculate' with the expression \"152648 + 485\". That should give the correct result. No need for any other steps here since the function will handle the calculation.\n",
"tool_calls": [
{
"id": "call_hkwxl4ae",
"type": "function",
"function": {
"name": "calculate",
"arguments": {
"expression": "152648 + 485"
}
}
}
]
},
{
"role": "tool",
"content": {
"result": 153133.0,
"log": "Successfully executed"
},
"tool_call_id": "call_hkwxl4ae"
}
]
}
]
[Synalinks]
Call ID: 1d558f6a-fcbf-4bde-9899-6c9c20da6279
Parent call ID: 4f610cad-74cb-404f-8f5d-dea1710a11a3
Module: LanguageModel
Module Name: language_model
Module Description: A language model API wrapper.
Data Model JSON:
[
{
"messages": [
{
"role": "system",
"content": "<instructions>\nThink step by step: Use the thinking field to elaborate what you observe and\nwhat do you need to accomplish next.\nReflect on prior steps: Review your previous actions and their outcomes to\navoid unnecessary repetition.\nAvoid unnecessary actions: If you already have enough information to complete\nthe user task, return an empty tool calls array.\n</instructions>\n"
},
{
"role": "user",
"content": "<input>\n{'query': 'How much is 152648 + 485?'}\n</input>\n<output>\n"
},
{
"role": "assistant",
"reasoning_content": "Okay, the user is asking \"How much is 152648 + 485?\" So I need to calculate the sum of 152,648 and 485. Let me check if I have the right tools for this. The available function is 'calculate', which takes a mathematical expression as a string. The expression here is straightforward: adding two numbers. I should format the numbers correctly, making sure there are no typos. Let me verify the numbers again—152,648 and 485. Adding them together: 152,648 plus 400 is 153,048, then plus 85 more would be 153,133. Wait, but maybe I should just use the function to compute it accurately. The function can handle the addition, so I'll call 'calculate' with the expression \"152648 + 485\". That should give the correct result. No need for any other steps here since the function will handle the calculation.\n",
"content": "",
"tool_calls": [
{
"id": "call_hkwxl4ae",
"type": "function",
"function": {
"name": "calculate",
"arguments": {
"expression": "152648 + 485"
}
}
}
]
},
{
"role": "tool",
"content": {
"result": 153133.0,
"log": "Successfully executed"
},
"tool_call_id": "call_hkwxl4ae"
}
]
}
]
[Synalinks]
Call ID: 1d558f6a-fcbf-4bde-9899-6c9c20da6279
Parent call ID: 4f610cad-74cb-404f-8f5d-dea1710a11a3
Module: LanguageModel
Module Name: language_model
Module Description: A language model API wrapper.
Data Model JSON:
[
{
"final_answer": 153133.0
}
]
[Synalinks]
Call ID: 4f610cad-74cb-404f-8f5d-dea1710a11a3
Parent call ID: 26f25409-dcfd-4c60-b9b6-c6ef040a39a5
Module: Generator
Module Name: final_generator_function_calling_agent
Module Description: Use a `LanguageModel` to generate a data model from an arbitrary input data model.
Data Model JSON:
[
{
"final_answer": 153133.0
}
]
[Synalinks]
Call ID: aa183ea2-9217-49c0-ba61-d0772042edc9
Parent call ID: 700303e8-f5b2-4537-a4cf-60e52284e4fb
Module: FunctionCallingAgent
Module Name: function_calling_agent
Module Description: A trainable parallel function calling agent.
Data Model JSON:
[
{
"messages": [
{
"role": "assistant",
"reasoning_content": "Okay, the user is asking \"How much is 152648 + 485?\" So I need to calculate the sum of 152,648 and 485. Let me check if I have the right tools for this. The available function is 'calculate', which takes a mathematical expression as a string. The expression here is straightforward: adding two numbers. I should format the numbers correctly, making sure there are no typos. Let me verify the numbers again—152,648 and 485. Adding them together: 152,648 plus 400 is 153,048, then plus 85 more would be 153,133. Wait, but maybe I should just use the function to compute it accurately. The function can handle the addition, so I'll call 'calculate' with the expression \"152648 + 485\". That should give the correct result. No need for any other steps here since the function will handle the calculation.\n",
"content": "",
"tool_calls": [
{
"id": "call_hkwxl4ae",
"type": "function",
"function": {
"name": "calculate",
"arguments": {
"expression": "152648 + 485"
}
}
}
]
},
{
"role": "tool",
"content": {
"result": 153133.0,
"log": "Successfully executed"
},
"tool_call_id": "call_hkwxl4ae"
}
],
"final_answer": 153133.0
}
]
[Synalinks]
Call ID: 700303e8-f5b2-4537-a4cf-60e52284e4fb
Parent call ID: None
Module: Functional
Module Name: math_agent
Module Description: A math agent
Data Model JSON:
[
{
"messages": [
{
"role": "assistant",
"reasoning_content": "Okay, the user is asking \"How much is 152648 + 485?\" So I need to calculate the sum of 152,648 and 485. Let me check if I have the right tools for this. The available function is 'calculate', which takes a mathematical expression as a string. The expression here is straightforward: adding two numbers. I should format the numbers correctly, making sure there are no typos. Let me verify the numbers again—152,648 and 485. Adding them together: 152,648 plus 400 is 153,048, then plus 85 more would be 153,133. Wait, but maybe I should just use the function to compute it accurately. The function can handle the addition, so I'll call 'calculate' with the expression \"152648 + 485\". That should give the correct result. No need for any other steps here since the function will handle the calculation.\n",
"content": "",
"tool_calls": [
{
"id": "call_hkwxl4ae",
"type": "function",
"function": {
"name": "calculate",
"arguments": {
"expression": "152648 + 485"
}
}
}
]
},
{
"role": "tool",
"content": {
"result": 153133.0,
"log": "Successfully executed"
},
"tool_call_id": "call_hkwxl4ae"
}
],
"final_answer": 153133.0
}
]
Creating the autonomous agent...
Running the agent...
{
"messages": [
{
"role": "assistant",
"reasoning_content": "Okay, the user is asking \"How much is 152648 + 485?\" So I need to calculate the sum of 152,648 and 485. Let me check if I have the right tools for this. The available function is 'calculate', which takes a mathematical expression as a string. The expression here is straightforward: adding two numbers. I should format the numbers correctly, making sure there are no typos. Let me verify the numbers again—152,648 and 485. Adding them together: 152,648 plus 400 is 153,048, then plus 85 more would be 153,133. Wait, but maybe I should just use the function to compute it accurately. The function can handle the addition, so I'll call 'calculate' with the expression \"152648 + 485\". That should give the correct result. No need for any other steps here since the function will handle the calculation.\n",
"content": "",
"tool_calls": [
{
"id": "call_hkwxl4ae",
"type": "function",
"function": {
"name": "calculate",
"arguments": {
"expression": "152648 + 485"
}
}
}
]
},
{
"role": "tool",
"content": {
"result": 153133.0,
"log": "Successfully executed"
},
"tool_call_id": "call_hkwxl4ae"
}
],
"final_answer": 153133.0
}
