Skip to content

Commit 6851aa8

Browse files
committed
debug
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
1 parent 4211b27 commit 6851aa8

2 files changed

Lines changed: 23 additions & 24 deletions

File tree

mcpserver/core/base.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@ class WorkerBase:
1515
ask secretary. We provide it here so that a hub can use it to generate
1616
its dual mode (acting as worker AND hub.)
1717
"""
18+
def jsonify_response(self, response):
19+
"""
20+
Ensure we get the text, and separate and parse tool calls,
21+
which the agent will return in a verbose mode.
22+
"""
23+
result = response.content[0].text
24+
25+
# Audit the tool calls (Did the agent just get lucky?)
26+
calls = []
27+
if "CALLS" in result:
28+
try:
29+
result, calls_block = result.split("CALLS")
30+
calls = utils.format_calls(calls_block)
31+
except:
32+
print(f"Issue parsing calls, agent had malformed response: {result}")
33+
pass
34+
35+
result = json.loads(utils.extract_code_block(result))
36+
result["calls"] = calls
37+
return result
1838

1939
def init_providers(self, mock=False):
2040
"""
@@ -73,9 +93,9 @@ async def receive_job(request: str) -> dict:
7393
agent = SecretaryAgent(active_providers, verbose=self.verbose)
7494
raw_result = await agent.submit(request)
7595
try:
76-
receipt = json.loads(utils.extract_code_block(raw_result))
77-
except:
78-
receipt = {"status": "FAILED", "reasoning": raw_result}
96+
receipt = self.jsonify_response(raw_result)
97+
except Exception as e:
98+
receipt = {"status": "FAILED", "reasoning": raw_result, "error": str(e)}
7999

80100
return {"worker_id": self.worker_id, "receipt": receipt}
81101

mcpserver/core/hub.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,6 @@ def _print_banner(self):
125125
print(" Workers must use this secret to join the hub")
126126
print(f" mcpserver start --join {self.registration_url}\n")
127127

128-
def jsonify_response(self, response):
129-
"""
130-
Ensure we get the text, and separate and parse tool calls,
131-
which the agent will return in a verbose mode.
132-
"""
133-
result = response.content[0].text
134-
135-
# Audit the tool calls (Did the agent just get lucky?)
136-
calls = []
137-
if "CALLS" in result:
138-
try:
139-
result, calls_block = result.split("CALLS")
140-
calls = utils.format_calls(calls_block)
141-
except:
142-
print(f"Issue parsing calls, agent had malformed response: {result}")
143-
pass
144-
145-
result = json.loads(utils.extract_code_block(result))
146-
result["calls"] = calls
147-
return result
148-
149128
async def run_on_fleet_parallel(self, action_fn) -> Dict[str, Any]:
150129
"""
151130
Run parallel sessions across all workers.

0 commit comments

Comments
 (0)