Skip to content

Commit eb832e3

Browse files
authored
Improve Agent logging (#136)
Improved agent logging for consistency, readability, and information. - Re-formatted the logging information of the agents (and added some colorized font to enhance readability) - Switched some logging from `info` to `debug` level - Removed some duplicated logging - Updated console output examples in `README` The original logging: <img width="1032" alt="Screenshot 2025-04-23 at 20 41 02" src="https://github.com/user-attachments/assets/f98b58fe-35f4-4246-994d-70ce7e784246" /> The updated logging: <img width="804" alt="Screenshot 2025-04-23 at 20 40 26" src="https://github.com/user-attachments/assets/9711f0cb-04c6-4ac8-9f80-c6a839e1a5bb" /> Closes [AIQ-933](https://jirasw.nvidia.com/browse/AIQ-933?filter=-1) ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/AgentIQ/blob/develop/docs/source/advanced/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. Authors: - Yuchen Zhang (https://github.com/yczhang-nv) - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) - David Gardner (https://github.com/dagardner-nv) - Michael Demoret (https://github.com/mdemoret-nv) - https://github.com/gzitzlsb-nv - Snehlata (https://github.com/atalhens) - Andrey Voroshilov (https://github.com/avoroshilov) - Bruno Alvisio (https://github.com/balvisio) - Eric Evans II (https://github.com/ericevans-nv) - Dhruv Nandakumar (https://github.com/dnandakumar-nv) Approvers: - Michael Demoret (https://github.com/mdemoret-nv) URL: #136
1 parent b5ca8ea commit eb832e3

File tree

23 files changed

+1044
-585
lines changed

23 files changed

+1044
-585
lines changed

examples/agents/mixture_of_agents/README.md

Lines changed: 48 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -71,60 +71,66 @@ aiq run --config_file=examples/agents/mixture_of_agents/configs/config.yml --inp
7171

7272
```console
7373
$ aiq run --config_file=examples/agents/mixture_of_agents/configs/config.yml --input "who was Djikstra?"
74-
2025-02-11 17:50:38,377 - aiq.cli.commands.run - INFO - Loading configuration from: examples/agents/mixture_of_agents/configs/config.yml
75-
2025-02-11 17:50:40,013 - aiq.profiler.callbacks.crewai_callback_handler - ERROR - Failed to import crewAI or a sub-module: No module named 'litellm'
76-
/Users/sjaviya/Documents/AgentIQ/sjaviya/ai-query-engine/.tempvenv/lib/python3.12/site-packages/langchain_nvidia_ai_endpoints/chat_models.py:591: UserWarning: Model 'meta/llama-3.3-70b-instruct' is not known to support tools. Your tool binding may fail at inference time.
77-
warnings.warn(
78-
2025-02-11 17:50:41,337 - aiq.agent.tool_calling_agent.agent - INFO - Initialized Tool Calling Agent Graph
79-
2025-02-11 17:50:41,337 - aiq.agent.tool_calling_agent.agent - INFO - Tool Calling Agent Graph built and compiled successfully
80-
/Users/sjaviya/Documents/AgentIQ/sjaviya/ai-query-engine/.tempvenv/lib/python3.12/site-packages/langchain_nvidia_ai_endpoints/chat_models.py:591: UserWarning: Model 'meta/llama-3.3-70b-instruct' is not known to support tools. Your tool binding may fail at inference time.
81-
warnings.warn(
82-
2025-02-11 17:50:41,560 - aiq.agent.tool_calling_agent.agent - INFO - Initialized Tool Calling Agent Graph
83-
2025-02-11 17:50:41,561 - aiq.agent.tool_calling_agent.agent - INFO - Tool Calling Agent Graph built and compiled successfully
84-
2025-02-11 17:50:41,561 - aiq.tool.code_generation_tool - INFO - Initializing code generation tool
74+
2025-04-23 14:57:12,020 - aiq.runtime.loader - WARNING - Loading module 'aiq_automated_description_generation.register' from entry point 'aiq_automated_description_generation' took a long time (503.239393 ms). Ensure all imports are inside your registered functions.
75+
2025-04-23 14:57:12,284 - aiq.cli.commands.start - INFO - Starting AgentIQ from config file: 'examples/agents/mixture_of_agents/configs/config.yml'
76+
2025-04-23 14:57:12,293 - aiq.cli.commands.start - WARNING - The front end type in the config file (fastapi) does not match the command name (console). Overwriting the config file front end.
77+
2025-04-23 14:57:12,375 - aiq.profiler.utils - WARNING - Discovered frameworks: {<LLMFrameworkEnum.LANGCHAIN: 'langchain'>} in function code_generation_tool by inspecting source. It is recommended and more reliable to instead add the used LLMFrameworkEnum types in the framework_wrappers argument when calling @register_function.
78+
2025-04-23 14:57:12,375 - aiq.plugins.langchain.tools.code_generation_tool - INFO - Initializing code generation tool
8579
Getting tool LLM from config
86-
2025-02-11 17:50:41,746 - aiq.tool.code_generation_tool - INFO - Filling tool's prompt variable from config
87-
2025-02-11 17:50:41,746 - aiq.tool.code_generation_tool - INFO - Initialized code generation tool
88-
2025-02-11 17:50:42,182 - aiq.agent.react_agent.agent - INFO - Filling the prompt variables "tools" and "tool_names", using the tools provided in the config.
89-
2025-02-11 17:50:42,182 - aiq.agent.react_agent.agent - INFO - Initialized ReAct Agent Graph
90-
2025-02-11 17:50:42,183 - aiq.agent.react_agent.agent - INFO - ReAct Graph built and compiled successfully
80+
2025-04-23 14:57:12,376 - aiq.plugins.langchain.tools.code_generation_tool - INFO - Filling tool's prompt variable from config
81+
2025-04-23 14:57:12,376 - aiq.plugins.langchain.tools.code_generation_tool - INFO - Initialized code generation tool
9182

9283
Configuration Summary:
9384
--------------------
9485
Workflow Type: react_agent
95-
Number of Functions: 9
86+
Number of Functions: 8
9687
Number of LLMs: 2
9788
Number of Embedders: 0
9889
Number of Memory: 0
99-
100-
2025-02-11 17:50:42,185 - aiq.cli.commands.run - INFO - Processing input: ('who was Djikstra?',)
101-
2025-02-11 17:50:42,187 - aiq.agent.react_agent.agent - INFO - Querying agent, attempt: 1
102-
2025-02-11 17:50:43,906 - aiq.agent.react_agent.agent - INFO - The user's question was: who was Djikstra?
103-
2025-02-11 17:50:43,906 - aiq.agent.react_agent.agent - INFO - The agent's thoughts are:
104-
Thought: I need to find information about a person named Djikstra, I think he might be related to computer science or mathematics.
105-
90+
Number of Retrievers: 0
91+
92+
2025-04-23 14:57:14,060 - aiq.agent.react_agent.agent - INFO -
93+
------------------------------
94+
[AGENT]
95+
Agent input: who was Djikstra?
96+
Agent's thoughts:
97+
Thought: I should search the internet for information on Djikstra.
10698
Action: internet_agent
107-
Action Input: Djikstra
108-
109-
110-
2025-02-11 17:50:43,909 - aiq.agent.react_agent.agent - INFO - Calling tool internet_agent with input: Djikstra
111-
112-
2025-02-11 17:50:43,911 - aiq.agent.tool_calling_agent.agent - INFO - Calling agent
113-
2025-02-11 17:50:50,325 - aiq.agent.react_agent.agent - INFO - Querying agent, attempt: 1
114-
2025-02-11 17:50:52,418 - aiq.agent.react_agent.agent - INFO -
115-
116-
The agent's thoughts are:
99+
Action Input: {'input_message': 'Djikstra'}
100+
Observation
101+
------------------------------
102+
2025-04-23 14:57:20,638 - aiq.agent.tool_calling_agent.agent - INFO -
103+
------------------------------
104+
[AGENT]
105+
Agent input: Djikstra
106+
Agent's thoughts:
107+
content="Dijkstra's algorithm is a well-known algorithm in graph theory, named after the Dutch computer scientist Edsger W. Dijkstra. It is used to find the shortest path between two nodes in a graph. The algorithm works by maintaining a list of unvisited nodes and iteratively selecting the node with the shortest distance from the starting node. The distance to each node is updated as the algorithm progresses, and the node with the shortest distance is added to the list of visited nodes. The algorithm terminates when the destination node is reached, and the shortest path is constructed by tracing back the nodes from the destination to the starting node.\n\nDijkstra's algorithm has many applications in computer science and other fields, such as network routing, traffic optimization, and resource allocation. It is also used in many real-world problems, such as finding the shortest path between two cities, optimizing traffic flow, and scheduling tasks.\n\nThe algorithm has a time complexity of O(|E| + |V|log|V|) in the worst case, where |E| is the number of edges and |V| is the number of vertices in the graph. This makes it efficient for large graphs. However, it can be slow for very large graphs or graphs with a large number" additional_kwargs={} response_metadata={'role': 'assistant', 'content': "Dijkstra's algorithm is a well-known algorithm in graph theory, named after the Dutch computer scientist Edsger W. Dijkstra. It is used to find the shortest path between two nodes in a graph. The algorithm works by maintaining a list of unvisited nodes and iteratively selecting the node with the shortest distance from the starting node. The distance to each node is updated as the algorithm progresses, and the node with the shortest distance is added to the list of visited nodes. The algorithm terminates when the destination node is reached, and the shortest path is constructed by tracing back the nodes from the destination to the starting node.\n\nDijkstra's algorithm has many applications in computer science and other fields, such as network routing, traffic optimization, and resource allocation. It is also used in many real-world problems, such as finding the shortest path between two cities, optimizing traffic flow, and scheduling tasks.\n\nThe algorithm has a time complexity of O(|E| + |V|log|V|) in the worst case, where |E| is the number of edges and |V| is the number of vertices in the graph. This makes it efficient for large graphs. However, it can be slow for very large graphs or graphs with a large number", 'token_usage': {'prompt_tokens': 363, 'total_tokens': 613, 'completion_tokens': 250}, 'finish_reason': 'length', 'model_name': 'meta/llama-3.3-70b-instruct'} id='run-44bec667-41ec-43a8-bbe2-ecacfe0580e8-0' usage_metadata={'input_tokens': 363, 'output_tokens': 250, 'total_tokens': 613} role='assistant'
108+
------------------------------
109+
2025-04-23 14:57:20,641 - aiq.agent.react_agent.agent - INFO -
110+
------------------------------
111+
[AGENT]
112+
Calling tools: internet_agent
113+
Tool's input: {"input_message": "Djikstra"}
114+
Tool's response:
115+
Dijkstra's algorithm is a well-known algorithm in graph theory, named after the Dutch computer scientist Edsger W. Dijkstra. It is used to find the shortest path between two nodes in a graph. The algorithm works by maintaining a list of unvisited nodes and iteratively selecting the node with the shortest distance from the starting node. The distance to each node is updated as the algorithm progresses, and the node with the shortest distance is added to the list of visited nodes. The algorithm terminates when the destination node is reached, and the shortest path is constructed by tracing back the nodes from the destination to the starting node.
116+
117+
Dijkstra's algorithm has many applications in computer science and other fields, such as network routing, traffic optimization, and resource allocation. It is also used in many real-world problems, such as finding the shortest path between two cities, optimizing traffic flow, and scheduling tasks.
118+
119+
The algorithm has a time complexity of O(|E| +...
120+
------------------------------
121+
2025-04-23 14:57:22,680 - aiq.agent.react_agent.agent - INFO -
122+
------------------------------
123+
[AGENT]
124+
Agent input: who was Djikstra?
125+
Agent's thoughts:
117126
Thought: I now know the final answer
118-
Final Answer: Edsger W. Dijkstra was a computer scientist who created Dijkstra's algorithm, a well-known algorithm in graph theory used to find the shortest path between two nodes in a graph.
119-
2025-02-11 17:50:52,421 - aiq.cli.commands.run - INFO - --------------------------------------------------
127+
Final Answer: Edsger W. Dijkstra was a Dutch computer scientist, and Dijkstra's algorithm is a well-known algorithm in graph theory used to find the shortest path between two nodes in a graph.
128+
------------------------------
129+
2025-04-23 14:57:22,684 - aiq.front_ends.console.console_front_end_plugin - INFO -
130+
--------------------------------------------------
120131
Workflow Result:
121-
["Edsger W. Dijkstra was a computer scientist who created Dijkstra's algorithm, a well-known algorithm in graph theory used to find the shortest path between two nodes in a graph."]
132+
["Edsger W. Dijkstra was a Dutch computer scientist, and Dijkstra's algorithm is a well-known algorithm in graph theory used to find the shortest path between two nodes in a graph."]
122133
--------------------------------------------------
123-
Cleaning up react_agent workflow.
124-
Cleaning up react_agent workflow.
125-
Cleaning up react_agent workflow.
126-
2025-02-11 17:50:52,428 - aiq.cli.entrypoint - INFO - Total time: 14.10 sec
127-
2025-02-11 17:50:52,428 - aiq.cli.entrypoint - INFO - Pipeline runtime: 10.24 sec
128134
```
129135
---
130136

examples/agents/react/README.md

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -77,56 +77,60 @@ aiq run --config_file=examples/agents/react/configs/config.yml --input "who was
7777

7878
```console
7979
$ aiq run --config_file=examples/agents/react/configs/config.yml --input "who was Djikstra?"
80-
2025-02-07 15:53:11,036 - aiq.cli.run - INFO - Loading configuration from: examples/agents/react/configs/config.yml
81-
2025-02-07 15:53:21,508 - aiq.profiler.callbacks.crewai_callback_handler - ERROR - Failed to import crewAI or a sub-module: No module named 'litellm'
82-
2025-02-07 15:53:25,917 - aiq.profiler.callbacks.crewai_callback_handler - ERROR - Failed to import crewAI or a sub-module: No module named 'litellm'
83-
2025-02-07 15:53:26,290 - aiq.profiler.callbacks.crewai_callback_handler - ERROR - Failed to import crewAI or a sub-module: No module named 'litellm'
84-
2025-02-07 15:53:26,291 - aiq.profiler.callbacks.crewai_callback_handler - ERROR - Failed to import crewAI or a sub-module: No module named 'litellm'
85-
2025-02-07 15:53:26,291 - aiq.tool.code_generation_tool - INFO - Initializing code generation tool
80+
2025-04-23 14:59:18,848 - aiq.runtime.loader - WARNING - Loading module 'aiq_automated_description_generation.register' from entry point 'aiq_automated_description_generation' took a long time (508.361340 ms). Ensure all imports are inside your registered functions.
81+
2025-04-23 14:59:19,123 - aiq.cli.commands.start - INFO - Starting AgentIQ from config file: 'examples/agents/react/configs/config.yml'
82+
2025-04-23 14:59:19,130 - aiq.cli.commands.start - WARNING - The front end type in the config file (fastapi) does not match the command name (console). Overwriting the config file front end.
83+
2025-04-23 14:59:19,163 - aiq.profiler.utils - WARNING - Discovered frameworks: {<LLMFrameworkEnum.LANGCHAIN: 'langchain'>} in function code_generation_tool by inspecting source. It is recommended and more reliable to instead add the used LLMFrameworkEnum types in the framework_wrappers argument when calling @register_function.
84+
2025-04-23 14:59:19,164 - aiq.plugins.langchain.tools.code_generation_tool - INFO - Initializing code generation tool
8685
Getting tool LLM from config
87-
2025-02-07 15:53:26,578 - aiq.tool.code_generation_tool - INFO - Filling tool's prompt variable from config
88-
2025-02-07 15:53:26,578 - aiq.tool.code_generation_tool - INFO - Initialized code generation tool
89-
2025-02-07 15:53:26,580 - aiq.profiler.callbacks.crewai_callback_handler - ERROR - Failed to import crewAI or a sub-module: No module named 'litellm'
90-
2025-02-07 15:53:28,097 - aiq.agent.base - INFO - Initializing Agent Graph
91-
2025-02-07 15:53:28,097 - aiq.workflows.react_agent.agent - INFO - Filling the prompt variables "tools" and "tool_names", using the tools provided in the config.
92-
2025-02-07 15:53:28,097 - aiq.workflows.react_agent.agent - INFO - Initialized ReAct Agent Graph
93-
2025-02-07 15:53:28,097 - aiq.agent.base - INFO - Building and compiling the Agent Graph
94-
2025-02-07 15:53:28,100 - aiq.workflows.react_agent.agent - INFO - ReAct Graph built and compiled successfully
86+
2025-04-23 14:59:19,182 - aiq.plugins.langchain.tools.code_generation_tool - INFO - Filling tool's prompt variable from config
87+
2025-04-23 14:59:19,182 - aiq.plugins.langchain.tools.code_generation_tool - INFO - Initialized code generation tool
9588

9689
Configuration Summary:
9790
--------------------
98-
Workflow Type: EmptyFunctionConfig
99-
Number of Functions: 0
100-
Number of LLMs: 0
91+
Workflow Type: react_agent
92+
Number of Functions: 3
93+
Number of LLMs: 1
10194
Number of Embedders: 0
10295
Number of Memory: 0
96+
Number of Retrievers: 0
10397

104-
2025-02-07 15:53:28,103 - aiq.cli.run - INFO - Processing input: ('who was Djikstra?',)
105-
2025-02-07 15:53:28,106 - aiq.workflows.react_agent.agent - INFO - Querying agent, attempt: 1
106-
2025-02-07 15:53:28,962 - aiq.workflows.react_agent.agent - INFO - The user's question was: who was Djikstra?
107-
2025-02-07 15:53:28,962 - aiq.workflows.react_agent.agent - INFO - The agent's thoughts are:
98+
2025-04-23 14:59:20,179 - aiq.agent.react_agent.agent - INFO -
99+
------------------------------
100+
[AGENT]
101+
Agent input: who was Djikstra?
102+
Agent's thoughts:
108103
Thought: To answer this question, I need to find information about Djikstra.
109104

110105
Action: wikipedia_search
111-
Action Input: Djikstra
112-
113-
114-
2025-02-07 15:53:28,968 - aiq.workflows.react_agent.agent - INFO - Calling tool wikipedia_search with input: Djikstra
115-
116-
2025-02-07 15:53:31,700 - aiq.workflows.react_agent.agent - INFO - Querying agent, attempt: 1
117-
2025-02-07 15:53:33,313 - aiq.workflows.react_agent.agent - INFO -
118-
119-
The agent's thoughts are:
106+
Action Input: {'question': 'Djikstra'}
107+
108+
109+
------------------------------
110+
2025-04-23 14:59:24,922 - aiq.agent.react_agent.agent - INFO -
111+
------------------------------
112+
[AGENT]
113+
Calling tools: wikipedia_search
114+
Tool's input: {"question": "Djikstra"}
115+
Tool's response:
116+
<Document source="https://en.wikipedia.org/wiki/Edsger_W._Dijkstra" page=""/>
117+
Edsger Wybe Dijkstra ( DYKE-strə; Dutch: [ˈɛtsxər ˈʋibə ˈdɛikstraː] ; 11 May 1930 – 6 August 2002) was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist.
118+
Born in Rotterdam in the Netherlands, Dijkstra studied mathematics and physics and then theoretical physics at the University of Leiden. Adriaan van Wijngaarden offered him a job as the first computer programmer in the Netherlands at the Mathematical Centre in Amsterdam, where he worked from 1952 until 1962. He formulated and solved the shortest path problem in 1956, and in 1960 developed the first compiler for the programming language ALGOL 60 in conjunction with colleague Jaap A. Zonneveld. In 1962 he moved to Eindhoven, and later to Nuenen, where he became a professor in the Mathematics Department at the Technische Hogeschool Eindhoven. In the late 1960s he built the THE multiprogramming system, which influence...
119+
------------------------------
120+
2025-04-23 14:59:26,159 - aiq.agent.react_agent.agent - INFO -
121+
------------------------------
122+
[AGENT]
123+
Agent input: who was Djikstra?
124+
Agent's thoughts:
120125
Thought: I now know the final answer
121126

122-
Final Answer: Djikstra was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist. He is best known for his work on the shortest path problem and the development of Dijkstra's algorithm, which is used to find the shortest path between nodes in a weighted graph.
123-
2025-02-07 15:53:33,319 - aiq.cli.run - INFO - --------------------------------------------------
127+
Final Answer: Edsger Wybe Dijkstra was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist who made significant contributions to the field of computer science, including formulating and solving the shortest path problem and developing the first compiler for the programming language ALGOL 60.
128+
------------------------------
129+
2025-04-23 14:59:26,164 - aiq.front_ends.console.console_front_end_plugin - INFO -
130+
--------------------------------------------------
124131
Workflow Result:
125-
["Djikstra was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist. He is best known for his work on the shortest path problem and the development of Dijkstra's algorithm, which is used to find the shortest path between nodes in a weighted graph."]
132+
['Edsger Wybe Dijkstra was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist who made significant contributions to the field of computer science, including formulating and solving the shortest path problem and developing the first compiler for the programming language ALGOL 60.']
126133
--------------------------------------------------
127-
Cleaning up react_agent workflow.
128-
2025-02-07 15:53:33,334 - aiq.cli.entrypoint - INFO - Total time: 22.42 sec
129-
2025-02-07 15:53:33,334 - aiq.cli.entrypoint - INFO - Pipeline runtime: 5.23 sec
130134
```
131135
---
132136

0 commit comments

Comments
 (0)