Compare commits

...

1 Commits

Author SHA1 Message Date
6af162ed5e fix(cron): inject runtime env hint into cron system prompt (#378)
Some checks failed
Forge CI / smoke-and-build (pull_request) Failing after 17s
The agent doesn't know its execution environment. When running on
cloud, it blindly attempts localhost calls from the prompt.

Add _build_cron_env_hint() that generates a [CRON ENV] block:
- LOCAL: 'localhost access, SSH, local services available'
- CLOUD: 'NO localhost access, NO SSH, NO local services.
  If instructions reference localhost/Ollama/SSH, report the
  limitation instead of attempting.'

Injected into the prompt after resolve_turn_route() so the agent
knows its environment before executing any instructions.

Closes #378
2026-04-14 01:57:32 +00:00

View File

@@ -643,6 +643,36 @@ def _build_job_prompt(job: dict) -> str:
return "\n".join(parts)
def _build_cron_env_hint(base_url: str, provider: str, disabled_toolsets: list) -> str:
"""Build a runtime environment hint block for the cron system prompt.
Tells the agent about its execution environment so it can self-adjust
when instructions reference capabilities it doesn't have. (#378)
"""
try:
from agent.model_metadata import is_local_endpoint
except ImportError:
is_local_endpoint = lambda _: False
is_local = is_local_endpoint(base_url or "")
parts = ["[CRON ENV:"]
if is_local:
parts.append(f"Runtime: LOCAL ({provider or 'local'} at {base_url or 'localhost'})")
parts.append("Capabilities: localhost access, SSH, local services available.")
else:
parts.append(f"Runtime: CLOUD ({provider or 'cloud'} at {base_url or 'remote'})")
parts.append("Capabilities: NO localhost access, NO SSH, NO local services.")
parts.append("If instructions reference localhost/Ollama/SSH, report the limitation instead of attempting.")
if disabled_toolsets:
parts.append(f"Disabled tools: {', '.join(disabled_toolsets)}.")
parts.append("]")
return " ".join(parts)
def run_job(job: dict) -> tuple[bool, str, str, Optional[str]]:
"""
Execute a single cron job.