Spaces:
Running
Running
Commit
·
a6398e4
1
Parent(s):
bc74531
fix: address CodeRabbit Phase 7 nitpicks
Browse files- Add truncation helper to avoid ellipsis on short messages
- Verify query and evidence args in test_hypothesis_agent
src/orchestrator_magentic.py
CHANGED
|
@@ -34,6 +34,11 @@ from src.utils.models import AgentEvent, Evidence
|
|
| 34 |
logger = structlog.get_logger()
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
class MagenticOrchestrator:
|
| 38 |
"""
|
| 39 |
Magentic-based orchestrator - same API as Orchestrator.
|
|
@@ -181,7 +186,7 @@ Focus on:
|
|
| 181 |
if message_text:
|
| 182 |
return AgentEvent(
|
| 183 |
type="judging",
|
| 184 |
-
message=f"Manager ({kind}): {message_text
|
| 185 |
iteration=iteration,
|
| 186 |
)
|
| 187 |
|
|
@@ -229,23 +234,23 @@ Focus on:
|
|
| 229 |
if "search" in agent_name.lower():
|
| 230 |
return AgentEvent(
|
| 231 |
type="search_complete",
|
| 232 |
-
message=f"Search agent: {msg_text
|
| 233 |
iteration=iteration,
|
| 234 |
)
|
| 235 |
elif "hypothes" in agent_name.lower():
|
| 236 |
return AgentEvent(
|
| 237 |
type="hypothesizing",
|
| 238 |
-
message=f"Hypothesis agent: {msg_text
|
| 239 |
iteration=iteration,
|
| 240 |
)
|
| 241 |
elif "judge" in agent_name.lower():
|
| 242 |
return AgentEvent(
|
| 243 |
type="judge_complete",
|
| 244 |
-
message=f"Judge agent: {msg_text
|
| 245 |
iteration=iteration,
|
| 246 |
)
|
| 247 |
return AgentEvent(
|
| 248 |
type="judging",
|
| 249 |
-
message=f"{agent_name}: {msg_text
|
| 250 |
iteration=iteration,
|
| 251 |
)
|
|
|
|
| 34 |
logger = structlog.get_logger()
|
| 35 |
|
| 36 |
|
| 37 |
+
def _truncate(text: str, max_len: int = 100) -> str:
|
| 38 |
+
"""Truncate text with ellipsis only if needed."""
|
| 39 |
+
return f"{text[:max_len]}..." if len(text) > max_len else text
|
| 40 |
+
|
| 41 |
+
|
| 42 |
class MagenticOrchestrator:
|
| 43 |
"""
|
| 44 |
Magentic-based orchestrator - same API as Orchestrator.
|
|
|
|
| 186 |
if message_text:
|
| 187 |
return AgentEvent(
|
| 188 |
type="judging",
|
| 189 |
+
message=f"Manager ({kind}): {_truncate(message_text)}",
|
| 190 |
iteration=iteration,
|
| 191 |
)
|
| 192 |
|
|
|
|
| 234 |
if "search" in agent_name.lower():
|
| 235 |
return AgentEvent(
|
| 236 |
type="search_complete",
|
| 237 |
+
message=f"Search agent: {_truncate(msg_text)}",
|
| 238 |
iteration=iteration,
|
| 239 |
)
|
| 240 |
elif "hypothes" in agent_name.lower():
|
| 241 |
return AgentEvent(
|
| 242 |
type="hypothesizing",
|
| 243 |
+
message=f"Hypothesis agent: {_truncate(msg_text)}",
|
| 244 |
iteration=iteration,
|
| 245 |
)
|
| 246 |
elif "judge" in agent_name.lower():
|
| 247 |
return AgentEvent(
|
| 248 |
type="judge_complete",
|
| 249 |
+
message=f"Judge agent: {_truncate(msg_text)}",
|
| 250 |
iteration=iteration,
|
| 251 |
)
|
| 252 |
return AgentEvent(
|
| 253 |
type="judging",
|
| 254 |
+
message=f"{agent_name}: {_truncate(msg_text)}",
|
| 255 |
iteration=iteration,
|
| 256 |
)
|
tests/unit/agents/test_hypothesis_agent.py
CHANGED
|
@@ -97,3 +97,5 @@ async def test_hypothesis_agent_uses_embeddings(sample_evidence, mock_assessment
|
|
| 97 |
mock_format.assert_called_once()
|
| 98 |
_args, kwargs = mock_format.call_args
|
| 99 |
assert kwargs["embeddings"] == mock_embeddings
|
|
|
|
|
|
|
|
|
| 97 |
mock_format.assert_called_once()
|
| 98 |
_args, kwargs = mock_format.call_args
|
| 99 |
assert kwargs["embeddings"] == mock_embeddings
|
| 100 |
+
assert _args[0] == "query" # First positional arg is query
|
| 101 |
+
assert _args[1] == sample_evidence # Second positional arg is evidence
|