style: revert unrelated Black-style formatting churn (#3220)
The earlier commits picked up a large amount of Black-style reformatting
(multi-line frozenset / keyword-arg wrapping / docstring blanks / removed
parens) on top of the actual guard fix. @chengyongru flagged it; the
first pass reverted some but not all.
This restores nanobot/providers/base.py, runner.py, heartbeat/service.py,
and utils/evaluator.py to origin/main and reapplies only the guard logic:
- base.py: add should_execute_tools property
- runner.py / heartbeat/service.py / utils/evaluator.py: route through it
+ log a warning when has_tool_calls but finish_reason is anomalous
Net diff vs main is now +87/-4 (was +211/-102) — roughly 30 lines of real
logic, which is what the PR is actually about.
Behavior unchanged from previous HEAD; full suite still 2014 passed.
Made-with: Cursor
This commit is contained in:
@@ -93,18 +93,12 @@ class HeartbeatService:
|
||||
|
||||
response = await self.provider.chat_with_retry(
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a heartbeat agent. Call the heartbeat tool to report your decision.",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": (
|
||||
f"Current Time: {current_time_str(self.timezone)}\n\n"
|
||||
"Review the following HEARTBEAT.md and decide whether there are active tasks.\n\n"
|
||||
f"{content}"
|
||||
),
|
||||
},
|
||||
{"role": "system", "content": "You are a heartbeat agent. Call the heartbeat tool to report your decision."},
|
||||
{"role": "user", "content": (
|
||||
f"Current Time: {current_time_str(self.timezone)}\n\n"
|
||||
"Review the following HEARTBEAT.md and decide whether there are active tasks.\n\n"
|
||||
f"{content}"
|
||||
)},
|
||||
],
|
||||
tools=_HEARTBEAT_TOOL,
|
||||
model=self.model,
|
||||
@@ -113,7 +107,7 @@ class HeartbeatService:
|
||||
if not response.should_execute_tools:
|
||||
if response.has_tool_calls:
|
||||
logger.warning(
|
||||
"Ignoring tool calls under finish_reason='%s' in heartbeat",
|
||||
"Ignoring heartbeat tool calls under finish_reason='{}'",
|
||||
response.finish_reason,
|
||||
)
|
||||
return "skip", ""
|
||||
@@ -177,10 +171,7 @@ class HeartbeatService:
|
||||
|
||||
if response:
|
||||
should_notify = await evaluate_response(
|
||||
response,
|
||||
tasks,
|
||||
self.provider,
|
||||
self.model,
|
||||
response, tasks, self.provider, self.model,
|
||||
)
|
||||
if should_notify and self.on_notify:
|
||||
logger.info("Heartbeat: completed, delivering response")
|
||||
|
||||
Reference in New Issue
Block a user