Skip to content

add DebugAgent and debug_tools coverage#778

Open
shmbhvi101 wants to merge 2 commits into
mainfrom
feat/debug-agent
Open

add DebugAgent and debug_tools coverage#778
shmbhvi101 wants to merge 2 commits into
mainfrom
feat/debug-agent

Conversation

@shmbhvi101
Copy link
Copy Markdown
Contributor

@shmbhvi101 shmbhvi101 commented May 14, 2026

Summary
This change delivers the VS Code–tunnel–backed debug agent work end to end on the backend: 10 high-level debugger tools, registry and ToolService wiring, DebugAgent local_mode behavior and workflow prompt, UI progress strings, and automated tests that cover routing, per-tool behavior, and mock integration with the agent.

What’s included

Debugger tool package :

• 10 StructuredTool modules: debug_start, debug_stop, debug_set_breakpoints, debug_snapshot, debug_step_into, debug_step_out, debug_step_over, debug_continue, debug_select_frame, debug_list_sessions.
• debug_tunnel_utils.py: maps each operation to LocalServer /api/debug/* paths, applies operation-specific timeouts, normalizes { success, result?, error? }, and routes over socket tunnel or legacy HTTP tunnel (and optional local-server HTTP shortcut where the
environment resolves a reachable LocalServer without going through tunnel metadata).
• create_debug_tools() in init.py exposes a single registration surface for ToolService.

Registry & tooling:

• ToolCategory extended with "debug".
• TOOL_DEFINITIONS: entries for all 10 tools with local_mode_only: true (and read_only / idempotent on debug_list_sessions).
• DEBUG_TOOLS constant lists the canonical tool names.
• tool_service.py registers tools from create_debug_tools() alongside existing tunnel-backed helpers.

Debug agent:

• DebugAgent._build_agent(..., local_mode=...) appends debug_tools_prompt_section when local_mode is true.
• When local_mode, get_tools(...) is called again for debugger tools plus execute_terminal_command, search_text, search_files; missing names are logged.
• run / run_stream derive local_mode from ChatContext.

Product / UX copy:

• tool_helpers.py: get_tool_run_message() branches for every debug tool name for streaming/progress UX.

Registry population:

• population.py: debug is handled so annotations come from TOOL_DEFINITIONS (no accidental derivation as terminal/search).

Tests:

• test_debug_tunnel_utils.py: formatting + route_debug_command with mocks (no tunnel parameterized for all operations, socket success/errors, legacy HTTP tunnel).
• test_debug_structured_tools.py: per-tool assertions that payloads and route_debug_command invocation match expectations; tunnel-unavailable and missing-user behaviors for all 10 tools.
• test_debug_agent_integration.py: mock integration checks that local_mode changes the get_tools call shape and documents a start → breakpoints → snapshot sequence at the routing layer under socket stubs.

Summary by CodeRabbit

  • New Features

    • Interactive local debugging: start/stop, breakpoints, step (into/out/over/continue), snapshots, frame selection, session listing, watch management, and related helper tools.
    • Local-mode propagation so debugging tools and VS Code tunnel features are available for local runs.
    • Structured debug & search tools exposed for use in local-mode environments.
  • Infrastructure

    • Worker .env loading improved to prefer repo-root .env; startup script now exports .env vars.
    • Tool registry extended with a debug category.
  • Tests

    • New unit tests covering debug tools, tunneling, and agent integration.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Walkthrough

Threads local_mode through API and agent runtime, adds runtime sync, implements many VS Code tunnel-backed debug tools and tunnel routing/formatting, wires tools into ToolService/registry, updates environment/startup, and adds comprehensive unit/integration tests.

Changes

Debug Tools and Local Mode Support

Layer / File(s) Summary
Environment and Startup Configuration
app/celery/celery_app.py, scripts/start.sh
Celery worker resolves repo-root .env; scripts/start.sh exports .env variables to subprocesses.
Local Mode Threading through API Layers
app/modules/conversations/conversations_router.py, app/modules/conversations/conversation/conversation_controller.py
Router and controller accept and propagate local_mode into service.store_message for streaming and non-streaming flows.
Agent Execution Flow and Manager Initialization
app/modules/intelligence/agents/chat_agents/multi_agent/execution_flows.py
init_managers initializes the code-changes manager with conversation/agent/user/tunnel/repo/branch and local_mode.
PydanticAgent Runtime Context Synchronization
app/modules/intelligence/agents/chat_agents/pydantic_agent.py
New _sync_pydantic_rag_tool_runtime_context sets sandbox run context and initializes code-changes manager at start of run and run_stream.
DebugAgent Local Mode Support
app/modules/intelligence/agents/chat_agents/system_agents/debug_agent.py
DebugAgent._build_agent accepts local_mode, selects local vs default debug prompt, and appends debugger/search/terminal tools when local_mode is true; run/run_stream pass local_mode.
Tool Run and Response Messaging
app/modules/intelligence/agents/chat_agents/tool_helpers.py
get_tool_run_message and get_tool_response_message include explicit branches and previews for debug and debug-workflow tools.
Debug Tools Package & Aggregation
app/modules/intelligence/tools/debug_tools/__init__.py
create_debug_tools() aggregates all debug tool factories; module export restricted to factory.
Debug Tool Implementations — control & session
app/modules/intelligence/tools/debug_tools/debug_continue_tool.py, .../debug_list_sessions_tool.py, .../debug_set_breakpoints_tool.py, .../debug_start_tool.py, .../debug_stop_tool.py
Control and session tools implemented with Pydantic schemas, context reads, payload serialization, and route_debug_command wiring; factories return StructuredTools.
Debug Tool Implementations — stepping/select/snapshot
app/modules/intelligence/tools/debug_tools/debug_snapshot_tool.py, .../debug_select_frame_tool.py, .../debug_step_into_tool.py, .../debug_step_out_tool.py, .../debug_step_over_tool.py
Stepping/select/snapshot tools accept optional expressions (merged with persistent watches), serialize inputs, and route via debug tunnel; factories expose args_schema.
Debug Workflow Tools (parse/context/tests/watches)
app/modules/intelligence/tools/debug_tools/parse_debug_signal_tool.py, .../build_debug_context_tool.py, .../find_related_tests_tool.py, .../add_watch_tool.py, .../remove_watch_tool.py, .../list_watches_tool.py, .../watch_store.py
Backend helpers for parsing pasted signals, assembling debug context packets, finding related tests, and managing persistent watch expressions with an in-memory store.
Socket Tunnel Helper
app/modules/intelligence/tools/local_search_tools/tunnel_utils.py
_execute_via_socket_full_response added to retry socket calls and return full {success, result?, error?} dicts.
Debug Tunnel Routing and Formatting Infrastructure
app/modules/intelligence/tools/debug_tools/debug_tunnel_utils.py
Maps debug operations to LocalServer endpoints, normalizes extension payloads, attempts local HTTP fallback, routes via Socket.IO or HTTP, and formats operation-specific results (snapshot, breakpoints, sessions, launch-configs, adapters).
Tool Registry and Schema Updates
app/modules/intelligence/tools/registry/schema.py, app/modules/intelligence/tools/registry/definitions.py, app/modules/intelligence/tools/registry/population.py
Added debug category to ToolCategory, extended TOOL_DEFINITIONS with debug tool metadata and DEBUG_TOOLS constant; minor clarifying population comment added.
Tool Service and Search Tools Integration
app/modules/intelligence/tools/tool_service.py
ToolService imports and registers code-changes management tools, debug tools, and registers search_text and search_files StructuredTools requiring local-mode/tunnel.
Debug Agent Integration Tests
tests/unit/intelligence/agents/chat_agents/system_agents/test_debug_agent_integration.py
Tests validate DebugAgent tool wiring for local vs non-local, and a mocked Socket.IO debug session flow through route_debug_command.
Debug Tool Structured Tool Tests
tests/unit/intelligence/tools/debug_tools/test_debug_structured_tools.py
Parametrized tests assert each debug StructuredTool forwards correct operation/payload and covers missing-auth and missing-tunnel behaviors.
Debug Tunnel Utils Unit Tests
tests/unit/intelligence/tools/debug_tools/test_debug_tunnel_utils.py
Tests for format_debug_result formatting and route_debug_command routing across unknown ops, auth/missing-tunnel, socket success/failure, and legacy HTTP paths.
Dependency Updates
pyproject.toml, requirements.txt
Bump PyTorch requirement/pinned version to 2.12.x.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • potpie-ai/potpie#226: Touches ConversationController.post_message and related signature/option forwarding changes.
  • potpie-ai/potpie#412: Related edits to pydantic_agent execution wiring and runtime/tool context handling.
  • potpie-ai/potpie#557: Related changes to multi-agent init and code-changes-manager lifecycle initialization.

Suggested reviewers

  • Dsantra92
  • nndn
  • dhirenmathur

Poem

"🐰 I hopped through tunnels, code in paw,
Local mode unlocked the debugger's law,
Breakpoints set, snapshots bright,
Tools and tests now take flight,
Hooray — the rabbit wired it right!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.32% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'add DebugAgent and debug_tools coverage' accurately summarizes the main change: introduction of DebugAgent and comprehensive debug tools support with test coverage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/debug-agent

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Dsantra92 Dsantra92 self-requested a review May 14, 2026 06:49
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
app/modules/intelligence/tools/registry/definitions.py (1)

323-334: ⚡ Quick win

Derive DEBUG_TOOLS from TOOL_DEFINITIONS to avoid drift.

This duplicates the debug tool names already declared above, so future edits can desync the two lists.

♻️ Proposed refactor
-DEBUG_TOOLS: List[str] = [
-    "debug_start",
-    "debug_stop",
-    "debug_set_breakpoints",
-    "debug_snapshot",
-    "debug_step_into",
-    "debug_step_out",
-    "debug_step_over",
-    "debug_continue",
-    "debug_select_frame",
-    "debug_list_sessions",
-]
+DEBUG_TOOLS: List[str] = [
+    name for name, meta in TOOL_DEFINITIONS.items() if meta.get("category") == "debug"
+]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/modules/intelligence/tools/registry/definitions.py` around lines 323 -
334, The static DEBUG_TOOLS list duplicates definitions and should be derived
from TOOL_DEFINITIONS to prevent drift: replace the hardcoded DEBUG_TOOLS with a
computed list built from TOOL_DEFINITIONS (e.g., iterate TOOL_DEFINITIONS and
collect tool names that identify as debug tools — for example keys or objects
whose name starts with "debug_" or whose metadata/category is "debug"), ensuring
the new DEBUG_TOOLS variable contains the same string names as before by
filtering TOOL_DEFINITIONS and preserving ordering if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/modules/intelligence/tools/registry/definitions.py`:
- Around line 323-334: The static DEBUG_TOOLS list duplicates definitions and
should be derived from TOOL_DEFINITIONS to prevent drift: replace the hardcoded
DEBUG_TOOLS with a computed list built from TOOL_DEFINITIONS (e.g., iterate
TOOL_DEFINITIONS and collect tool names that identify as debug tools — for
example keys or objects whose name starts with "debug_" or whose
metadata/category is "debug"), ensuring the new DEBUG_TOOLS variable contains
the same string names as before by filtering TOOL_DEFINITIONS and preserving
ordering if needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0b0c3ea0-bb93-4ece-9d3b-23b1f3620fd0

📥 Commits

Reviewing files that changed from the base of the PR and between 57da75c and 24257d1.

📒 Files selected for processing (28)
  • app/celery/celery_app.py
  • app/modules/conversations/conversation/conversation_controller.py
  • app/modules/conversations/conversations_router.py
  • app/modules/intelligence/agents/chat_agents/multi_agent/execution_flows.py
  • app/modules/intelligence/agents/chat_agents/pydantic_agent.py
  • app/modules/intelligence/agents/chat_agents/system_agents/debug_agent.py
  • app/modules/intelligence/agents/chat_agents/tool_helpers.py
  • app/modules/intelligence/tools/debug_tools/__init__.py
  • app/modules/intelligence/tools/debug_tools/debug_continue_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_list_sessions_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_select_frame_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_set_breakpoints_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_snapshot_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_start_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_step_into_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_step_out_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_step_over_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_stop_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_tunnel_utils.py
  • app/modules/intelligence/tools/local_search_tools/tunnel_utils.py
  • app/modules/intelligence/tools/registry/definitions.py
  • app/modules/intelligence/tools/registry/population.py
  • app/modules/intelligence/tools/registry/schema.py
  • app/modules/intelligence/tools/tool_service.py
  • scripts/start.sh
  • tests/unit/intelligence/agents/chat_agents/system_agents/test_debug_agent_integration.py
  • tests/unit/intelligence/tools/debug_tools/test_debug_structured_tools.py
  • tests/unit/intelligence/tools/debug_tools/test_debug_tunnel_utils.py

…ting ones

- Introduced new debug tools: `add_watch`, `build_debug_context`, `find_related_tests`, `debug_list_launch_configs`, and `debug_list_adapters`.
- Updated `DebugAgent` to utilize new tools and improved task prompts for local debugging.
- Enhanced existing tools to support persistent watch expressions and improved context building from debug signals.
- Updated dependencies in `pyproject.toml` and `requirements.txt` to include `torch` version 2.12.0 and other necessary packages.
- Updated `uv.lock` to reflect changes in package versions and dependencies.
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
app/modules/intelligence/tools/debug_tools/watch_store.py (1)

29-34: ⚡ Quick win

Avoid creating store entries when removing from non-existent keys.

Lines 32-34 will create an empty list entry in _store when the key doesn't exist (e.g., calling remove_watch before any watches are added). This accumulates empty dictionary entries over time and is inconsistent with list_watches, which doesn't create entries.

♻️ Proposed fix to skip assignment for non-existent keys or cleanup empty results
 def remove_watch(user_id: Optional[str], conversation_id: Optional[str], expression: str) -> List[str]:
     k = _key(user_id, conversation_id)
     with _lock:
+        if k not in _store:
+            return []
         watches = _store.get(k, [])
         _store[k] = [w for w in watches if w != expression]
+        if not _store[k]:
+            del _store[k]
         return list(_store[k])
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/modules/intelligence/tools/debug_tools/watch_store.py` around lines 29 -
34, remove_watch currently creates an empty _store entry for non-existent keys;
update remove_watch (use _key, _store, and _lock) to first check if k is in
_store while holding _lock, return [] immediately if missing, otherwise filter
the existing list, and then either assign the filtered list back to _store[k] or
delete _store[k] when the filtered result is empty so you don't accumulate empty
entries (preserve thread-safety by performing the check, filter, assign/delete
inside the same _lock block).
app/modules/intelligence/tools/registry/definitions.py (1)

378-399: ⚡ Quick win

Derive DEBUG_TOOLS from TOOL_DEFINITIONS to avoid drift.

This manual list duplicates the debug keys already declared above. A future add/remove can easily desync behavior.

♻️ Proposed change
-DEBUG_TOOLS: List[str] = [
-    # DAP / extension tunnel
-    "debug_start",
-    "debug_stop",
-    "debug_set_breakpoints",
-    "debug_snapshot",
-    "debug_step_into",
-    "debug_step_out",
-    "debug_step_over",
-    "debug_continue",
-    "debug_select_frame",
-    "debug_list_sessions",
-    "debug_list_launch_configs",
-    "debug_list_adapters",
-    # Hypothesis workflow (backend-only)
-    "parse_debug_signal",
-    "build_debug_context",
-    "find_related_tests",
-    "add_watch",
-    "remove_watch",
-    "list_watches",
-]
+DEBUG_TOOLS: List[str] = [
+    name for name, meta in TOOL_DEFINITIONS.items() if meta.get("category") == "debug"
+]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/modules/intelligence/tools/registry/definitions.py` around lines 378 -
399, DEBUG_TOOLS is a manually maintained list that duplicates keys already
present in TOOL_DEFINITIONS; replace the hardcoded list by deriving it from
TOOL_DEFINITIONS to prevent drift by creating DEBUG_TOOLS from the
keys/definitions in TOOL_DEFINITIONS (e.g., filter keys that start with "debug_"
or match your debug predicate) while preserving the desired ordering and using
the same symbol name DEBUG_TOOLS so callers are unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/modules/intelligence/agents/chat_agents/system_agents/debug_agent.py`:
- Around line 130-133: The warning call in DebugAgent's local_mode uses a "{}"
placeholder which doesn't match Python logging interpolation; update the
logger.warning invocation in debug_agent.py (the DebugAgent local_mode warning)
to use consistent logging formatting, e.g. replace the "{}" placeholder with a
printf-style "%s" and pass missing as a second argument
(logger.warning("DebugAgent local_mode: requested tools missing from ToolService
— %s", missing)) or use an f-string (logger.warning(f"DebugAgent local_mode:
requested tools missing from ToolService — {missing}")) so the message
interpolates correctly.

In `@app/modules/intelligence/tools/debug_tools/parse_debug_signal_tool.py`:
- Around line 117-131: _extract_test_info currently only uses Jest regexes
(_JEST_EXPECTED and _JEST_RECEIVED) so pytest-style diffs leave expected/actual
empty; update _extract_test_info to, after attempting the Jest matches, fall
back to the pytest regexes (e.g. _PYTEST_EXPECTED and _PYTEST_ACTUAL or whatever
the pytest-pattern names are) to populate expected and received when the Jest
patterns return None, keeping the same trimming/length limit behavior and
preserving test_path extraction via _TEST_PATH.

---

Nitpick comments:
In `@app/modules/intelligence/tools/debug_tools/watch_store.py`:
- Around line 29-34: remove_watch currently creates an empty _store entry for
non-existent keys; update remove_watch (use _key, _store, and _lock) to first
check if k is in _store while holding _lock, return [] immediately if missing,
otherwise filter the existing list, and then either assign the filtered list
back to _store[k] or delete _store[k] when the filtered result is empty so you
don't accumulate empty entries (preserve thread-safety by performing the check,
filter, assign/delete inside the same _lock block).

In `@app/modules/intelligence/tools/registry/definitions.py`:
- Around line 378-399: DEBUG_TOOLS is a manually maintained list that duplicates
keys already present in TOOL_DEFINITIONS; replace the hardcoded list by deriving
it from TOOL_DEFINITIONS to prevent drift by creating DEBUG_TOOLS from the
keys/definitions in TOOL_DEFINITIONS (e.g., filter keys that start with "debug_"
or match your debug predicate) while preserving the desired ordering and using
the same symbol name DEBUG_TOOLS so callers are unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ab4acd48-5468-4610-ba2d-6a580561c91a

📥 Commits

Reviewing files that changed from the base of the PR and between 24257d1 and 4e443b6.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (21)
  • app/modules/intelligence/agents/chat_agents/system_agents/debug_agent.py
  • app/modules/intelligence/agents/chat_agents/tool_helpers.py
  • app/modules/intelligence/tools/debug_tools/__init__.py
  • app/modules/intelligence/tools/debug_tools/add_watch_tool.py
  • app/modules/intelligence/tools/debug_tools/build_debug_context_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_list_adapters_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_list_launch_configs_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_select_frame_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_snapshot_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_step_into_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_step_out_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_step_over_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_tunnel_utils.py
  • app/modules/intelligence/tools/debug_tools/find_related_tests_tool.py
  • app/modules/intelligence/tools/debug_tools/list_watches_tool.py
  • app/modules/intelligence/tools/debug_tools/parse_debug_signal_tool.py
  • app/modules/intelligence/tools/debug_tools/remove_watch_tool.py
  • app/modules/intelligence/tools/debug_tools/watch_store.py
  • app/modules/intelligence/tools/registry/definitions.py
  • pyproject.toml
  • requirements.txt
✅ Files skipped from review due to trivial changes (1)
  • pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/modules/intelligence/tools/debug_tools/debug_snapshot_tool.py
  • app/modules/intelligence/tools/debug_tools/debug_tunnel_utils.py

Comment on lines +130 to +133
logger.warning(
"DebugAgent local_mode: requested tools missing from ToolService — {}",
missing,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect logger factory implementation
fd -i "logger.py" app/modules/utils
rg -n -C3 "def setup_logger|logging.getLogger|loguru|structlog" app/modules/utils

# Inspect local usage in this file
rg -n -C2 "requested tools missing from ToolService|logger\\.warning\\(" app/modules/intelligence/agents/chat_agents/system_agents/debug_agent.py

Repository: potpie-ai/potpie

Length of output: 5587


Normalize warning interpolation to use consistent formatting.

Line 130–133 uses {} placeholder (str.format-style) with a positional argument, which is a format mismatch. The logger expects either f-string formatting or printf-style %s with positional args, not mixed styles.

Suggested fix
             if missing:
-                logger.warning(
-                    "DebugAgent local_mode: requested tools missing from ToolService — {}",
-                    missing,
-                )
+                logger.warning(
+                    f"DebugAgent local_mode: requested tools missing from ToolService — {missing}"
+                )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.warning(
"DebugAgent local_mode: requested tools missing from ToolService — {}",
missing,
)
logger.warning(
f"DebugAgent local_mode: requested tools missing from ToolService — {missing}"
)
🧰 Tools
🪛 Ruff (0.15.12)

[error] 130-130: Too many arguments for logging format string

(PLE1205)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/modules/intelligence/agents/chat_agents/system_agents/debug_agent.py`
around lines 130 - 133, The warning call in DebugAgent's local_mode uses a "{}"
placeholder which doesn't match Python logging interpolation; update the
logger.warning invocation in debug_agent.py (the DebugAgent local_mode warning)
to use consistent logging formatting, e.g. replace the "{}" placeholder with a
printf-style "%s" and pass missing as a second argument
(logger.warning("DebugAgent local_mode: requested tools missing from ToolService
— %s", missing)) or use an f-string (logger.warning(f"DebugAgent local_mode:
requested tools missing from ToolService — {missing}")) so the message
interpolates correctly.

Comment on lines +117 to +131
def _extract_test_info(text: str) -> Dict[str, Optional[str]]:
expected = received = test_path = None

m = _TEST_PATH.search(text)
if m:
test_path = m.group(1).strip()

m = _JEST_EXPECTED.search(text)
if m:
expected = m.group(1).strip()[:200]
m = _JEST_RECEIVED.search(text)
if m:
received = m.group(1).strip()[:200]

return {"expected": expected, "actual": received, "test_path": test_path}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add pytest fallback for expected/actual extraction.

Line 124–129 only use Jest patterns, so pytest-style diffs won’t populate expected/actual even though regexes already exist. Add fallback matching to avoid dropping key signal data.

💡 Proposed fix
 def _extract_test_info(text: str) -> Dict[str, Optional[str]]:
     expected = received = test_path = None
@@
     m = _JEST_EXPECTED.search(text)
     if m:
         expected = m.group(1).strip()[:200]
+    else:
+        m = _PYTEST_EXPECTED.search(text)
+        if m:
+            expected = m.group(1).strip()[:200]
+
     m = _JEST_RECEIVED.search(text)
     if m:
         received = m.group(1).strip()[:200]
+    else:
+        m = _PYTEST_RECEIVED.search(text)
+        if m:
+            received = m.group(1).strip()[:200]
 
     return {"expected": expected, "actual": received, "test_path": test_path}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/modules/intelligence/tools/debug_tools/parse_debug_signal_tool.py` around
lines 117 - 131, _extract_test_info currently only uses Jest regexes
(_JEST_EXPECTED and _JEST_RECEIVED) so pytest-style diffs leave expected/actual
empty; update _extract_test_info to, after attempting the Jest matches, fall
back to the pytest regexes (e.g. _PYTEST_EXPECTED and _PYTEST_ACTUAL or whatever
the pytest-pattern names are) to populate expected and received when the Jest
patterns return None, keeping the same trimming/length limit behavior and
preserving test_path extraction via _TEST_PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants