-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fixed JSON formatting #3475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed JSON formatting #3475
Changes from all commits
06560f7
2026ea0
b9f9056
51d5064
61e86ad
f0fe82a
3dad9e6
87a5068
07bdee1
1853e8f
f848e68
ba843d6
1ed9cba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ class ConsoleFormatter: | |
| def __init__(self, verbose: bool = False): | ||
| self.console = Console(width=None) | ||
| self.verbose = verbose | ||
| self.tool_usage_counts: dict[str, int] = {} | ||
| # Live instance to dynamically update a Tree renderable (e.g. the Crew tree) | ||
| # When multiple Tree objects are printed sequentially we reuse this Live | ||
| # instance so the previous render is replaced instead of writing a new one. | ||
|
|
@@ -693,7 +694,8 @@ def handle_llm_call_completed( | |
| if tool_branch is not None and "Thinking" in str(tool_branch.label): | ||
| thinking_branch_to_remove = tool_branch | ||
|
|
||
| # Method 2: Fallback - search for any thinking node if tool_branch is None or not thinking | ||
| # Method 2: Fallback - search for any thinking node if tool_branch is None | ||
| # or not thinking | ||
| if thinking_branch_to_remove is None: | ||
| parents = [ | ||
| self.current_lite_agent_branch, | ||
|
|
@@ -752,7 +754,8 @@ def handle_llm_call_failed( | |
| if tool_branch is not None and "Thinking" in str(tool_branch.label): | ||
| thinking_branch_to_update = tool_branch | ||
|
|
||
| # Method 2: Fallback - search for any thinking node if tool_branch is None or not thinking | ||
| # Method 2: Fallback - search for any thinking node if tool_branch is None or | ||
| # not thinking | ||
| if thinking_branch_to_update is None: | ||
| parents = [ | ||
| self.current_lite_agent_branch, | ||
|
|
@@ -1377,7 +1380,7 @@ def handle_agent_logs_execution( | |
| if isinstance(formatted_answer, AgentAction): | ||
| thought = re.sub(r"\n+", "\n", formatted_answer.thought) | ||
| formatted_json = json.dumps( | ||
| formatted_answer.tool_input, | ||
| json.loads(formatted_answer.tool_input), | ||
Vidit-Ostwal marked this conversation as resolved.
Show resolved
Hide resolved
Vidit-Ostwal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| indent=2, | ||
| ensure_ascii=False, | ||
| ) | ||
|
|
@@ -1592,10 +1595,14 @@ def handle_memory_query_completed( | |
| if "Sources Used" in str(inner_child.label): | ||
| sources_branch.add(f"✅ {memory_type} ({query_time_ms:.2f}ms)") | ||
| break | ||
| else: | ||
| sources_branch = child.add("Sources Used") | ||
| sources_branch.add(f"✅ {memory_type} ({query_time_ms:.2f}ms)") | ||
| break | ||
|
|
||
| # If not found, create it under this child | ||
| if sources_branch is None: | ||
| sources_branch = child.add("🧠 Sources Used") | ||
|
|
||
| sources_branch.add(f"✅ {memory_type} ({query_time_ms:.2f}ms)") | ||
| break | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Memory Query Handling FailsThe refactored logic in Additional Locations (1) |
||
|
|
||
| def handle_memory_query_failed( | ||
| self, | ||
|
|
@@ -1625,10 +1632,14 @@ def handle_memory_query_failed( | |
| if "Sources Used" in str(inner_child.label): | ||
| sources_branch.add(f"❌ {memory_type} - Error: {error}") | ||
| break | ||
| else: | ||
|
|
||
| # If not found, create it under this child | ||
| if sources_branch is None: | ||
| sources_branch = child.add("🧠 Sources Used") | ||
| sources_branch.add(f"❌ {memory_type} - Error: {error}") | ||
| break | ||
|
|
||
| sources_branch.add(f"❌ {memory_type} - Error: {error}") | ||
| break | ||
|
|
||
|
|
||
| def handle_memory_save_started( | ||
| self, agent_branch: Tree | None, crew_tree: Tree | None | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Instance Variable Shadows Class Variable
The
tool_usage_countsinstance variable, initialized in__init__, shadows the class variable of the same name. This prevents tool usage from being tracked globally across all instances, leading to each instance having its own isolated count instead of a shared one.