fix(cron): inject cloud-context warning when prompt refs localhost #468

Closed
Rockachopa wants to merge 246 commits from fix/456-cloud-context-warning into main
Owner

Fix

Fixes #378, Closes #456

When a cron job runs on a cloud endpoint but its prompt references local services (Ollama, localhost, etc.), inject a [SYSTEM NOTE] telling the agent it cannot reach localhost.

How it works

  1. Detection_detect_local_service_refs() scans the prompt against 12 regex patterns (localhost:PORT, 127.x, "Check Ollama", curl localhost, etc.)
  2. Cloud check — uses existing is_local_endpoint() to determine if the runtime is cloud
  3. Injection — if cloud + local refs found, _inject_cloud_context() prepends a warning so the agent reports the limitation instead of wasting iterations on doomed connections

Changes

  • cron/scheduler.py: Added import re, _LOCAL_SERVICE_PATTERNS, _detect_local_service_refs(), _inject_cloud_context(). Injection call after cloud detection in run_job().
  • tests/test_cron_cloud_context.py: 15 tests covering pattern detection, warning injection, false-positive avoidance.
## Fix Fixes #378, Closes #456 When a cron job runs on a cloud endpoint but its prompt references local services (Ollama, localhost, etc.), inject a `[SYSTEM NOTE]` telling the agent it cannot reach localhost. ### How it works 1. **Detection** — `_detect_local_service_refs()` scans the prompt against 12 regex patterns (localhost:PORT, 127.x, "Check Ollama", curl localhost, etc.) 2. **Cloud check** — uses existing `is_local_endpoint()` to determine if the runtime is cloud 3. **Injection** — if cloud + local refs found, `_inject_cloud_context()` prepends a warning so the agent reports the limitation instead of wasting iterations on doomed connections ### Changes - `cron/scheduler.py`: Added `import re`, `_LOCAL_SERVICE_PATTERNS`, `_detect_local_service_refs()`, `_inject_cloud_context()`. Injection call after cloud detection in `run_job()`. - `tests/test_cron_cloud_context.py`: 15 tests covering pattern detection, warning injection, false-positive avoidance.
Rockachopa added 2 commits 2026-04-14 01:18:23 +00:00
Fixes #378, Closes #456

When a cron job runs on a cloud endpoint but its prompt references
local services (Ollama, localhost ports, etc.), inject a SYSTEM NOTE
telling the agent it cannot reach localhost so it reports the
limitation instead of wasting iterations on doomed connections.
test(cron): add tests for cloud-context warning injection
Some checks failed
Forge CI / smoke-and-build (pull_request) Failing after 1m13s
7ac8d0268f
Author
Owner

PR #481 created to address this issue: #481

This PR implements cloud context warning injection for cron jobs that reference local services. When a cron job runs on a cloud endpoint but its prompt references local services (Ollama, localhost, etc.), the system now injects a warning telling the agent it cannot reach localhost.

Key changes:

  1. Added _LOCAL_SERVICE_PATTERNS with 12 regex patterns for detecting local service references
  2. Added _detect_local_service_refs() to scan prompts for local service references
  3. Added _inject_cloud_context() to prepend warning to prompts
  4. Integrated injection in run_job() after prompt build, before agent creation
  5. Created comprehensive tests in tests/test_cron_cloud_context.py

The fix ensures that agents running on cloud endpoints report limitations to users instead of wasting iterations trying to connect to non-existent local services.

PR #481 created to address this issue: https://forge.alexanderwhitestone.com/Timmy_Foundation/hermes-agent/pulls/481 This PR implements cloud context warning injection for cron jobs that reference local services. When a cron job runs on a cloud endpoint but its prompt references local services (Ollama, localhost, etc.), the system now injects a warning telling the agent it cannot reach localhost. Key changes: 1. Added `_LOCAL_SERVICE_PATTERNS` with 12 regex patterns for detecting local service references 2. Added `_detect_local_service_refs()` to scan prompts for local service references 3. Added `_inject_cloud_context()` to prepend warning to prompts 4. Integrated injection in `run_job()` after prompt build, before agent creation 5. Created comprehensive tests in `tests/test_cron_cloud_context.py` The fix ensures that agents running on cloud endpoints report limitations to users instead of wasting iterations trying to connect to non-existent local services.
Rockachopa closed this pull request 2026-04-14 01:50:21 +00:00
Some checks failed
Forge CI / smoke-and-build (pull_request) Failing after 1m13s

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/hermes-agent#468