Skip to content

Commit e2a961d

Browse files
committed
fix: address PR review feedback and fix ruff format CI failure
- Reorder imports: stdlib before third-party (fixes Paolo nit) - Add warning log when prereq JSON parsing falls back to empty defaults - Add comment documenting flat-JSON-only regex limitation - Run ruff format to fix string quoting style in agents.py Signed-off-by: Mariusz Sabath <mrsabath@gmail.com>
1 parent 24056ca commit e2a961d

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

a2a/git_issue_agent/git_issue_agent/agents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, config: Settings, issue_tools):
2424
agent=self.prereq_identifier,
2525
expected_output=(
2626
'A JSON object with keys "owner", "repo", and "issue_numbers". '
27-
"Example: {\"owner\": \"kagenti\", \"repo\": \"kagenti\", \"issue_numbers\": null}"
27+
'Example: {"owner": "kagenti", "repo": "kagenti", "issue_numbers": null}'
2828
),
2929
)
3030

a2a/git_issue_agent/git_issue_agent/main.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
from crewai_tools.adapters.tool_collection import ToolCollection
2-
31
import json
42
import logging
53
import re
64
import sys
75

6+
from crewai_tools.adapters.tool_collection import ToolCollection
7+
8+
from git_issue_agent.agents import GitAgents
89
from git_issue_agent.config import Settings, settings
910
from git_issue_agent.data_types import IssueSearchInfo
1011
from git_issue_agent.event import Event
11-
from git_issue_agent.agents import GitAgents
1212

1313
logger = logging.getLogger(__name__)
1414
logging.basicConfig(level=settings.LOG_LEVEL, stream=sys.stdout, format="%(levelname)s: %(message)s")
@@ -20,16 +20,17 @@ def _parse_prereq_from_raw(raw: str) -> IssueSearchInfo:
2020
Some Ollama models don't produce structured tool calls that crewai's instructor
2121
integration expects. This fallback extracts JSON from the raw text output.
2222
"""
23-
# Try to find JSON in the raw output
24-
json_match = re.search(r'\{[^{}]*\}', raw)
23+
# Only matches flat JSON (no nested braces). Sufficient for the current
24+
# IssueSearchInfo schema; revisit if the model gains nested fields.
25+
json_match = re.search(r"\{[^{}]*\}", raw)
2526
if json_match:
2627
try:
2728
data = json.loads(json_match.group())
2829
return IssueSearchInfo(**data)
2930
except (json.JSONDecodeError, ValueError):
3031
pass
3132

32-
# Fallback: return empty IssueSearchInfo (no pre-identified fields)
33+
logger.warning("Could not parse prereq JSON from raw output: %s", raw)
3334
return IssueSearchInfo()
3435

3536

0 commit comments

Comments
 (0)