Skip to content

fix(cron): gateway-loop delivery, per-run prompt context, Matrix standalone send — run-action sweep salvage - #80838

Merged
teknium1 merged 4 commits into
mainfrom
fix/cron-sweep-salvage
Aug 7, 2026
Merged

fix(cron): gateway-loop delivery, per-run prompt context, Matrix standalone send — run-action sweep salvage#80838
teknium1 merged 4 commits into
mainfrom
fix/cron-sweep-salvage

Conversation

@teknium1

@teknium1 teknium1 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Cluster salvage of the three surviving fixes from the cronjob(action='run') sweep (follow-up to #80807): manual runs now deliver on the live gateway loop (fixes Matrix delivery, #61495), accept transient per-run prompt context (#57331), and Matrix standalone send no longer crashes on aiohttp's task-context check.

Changes

Validation

Before After
Manual run → Matrix delivery "Timeout context manager..." error delivered on gateway loop
cronjob(run, prompt=...) prompt silently discarded ## Run Context in assembled prompt
Injection attempt in run prompt n/a (discarded) blocked by _scan_cron_prompt
Job definition after context run unchanged unchanged (verified)
Targeted suites 506/506 cron+tool, 155/155 Matrix

E2E (real job store, temp HERMES_HOME): background run with prompt="CONTEXT: client=Acme" → assembled prompt contains stored prompt + ## Run Context + context; stored job untouched; injection-shaped context refused with the scanner error before any fire.

Attribution: commits cherry-picked/salvaged preserve @Fly-onlyone and @liuhao1024 authorship (audit green).

Infographic

cron sweep salvage

Fly-onlyone and others added 4 commits August 6, 2026 22:58
Pins the scheduler-boundary contract: extra_prompt is appended under
'## Run Context', does not mutate job['prompt'], and the header is
absent when extra_prompt is omitted.

Addresses review feedback from harjothkhara on PR #57342.
Salvaged from PR #57342 by @liuhao1024 (with the injection-scan half
from PR #57360 by @ghedeselmabot): cronjob(action='run', prompt=...)
silently discarded the prompt argument — per-run context never
reached the spawned cron session.

The prompt is now threaded as extra_prompt through the whole chain
(cronjob run action → _try_dispatch_background_run/_execute_job_now →
_run_claimed_job → run_one_job → run_job → _build_job_prompt) and
appended to the stored prompt under a '## Run Context' header for
that single fire only — never persisted to the job definition. It
passes the same strict _scan_cron_prompt injection scan as stored
prompts before firing, and works identically on the background and
sync fallback paths.

Test fakes across tests/cron/ updated to accept the new kwargs
(sibling-test blast radius from the signature change).

Co-authored-by: liuhao1024 <liuhao1024@users.noreply.github.com>
… standalone send

Fixes #61495

When manually triggering cron jobs from a live Matrix session, delivery
would fail with "Timeout context manager should be used inside a task"
because the aiohttp.ClientTimeout context manager requires a proper asyncio
task context.

Use asyncio.wait_for() instead of aiohttp.ClientTimeout to avoid this error,
following the same pattern as the Weixin platform (gateway/platforms/weixin.py).

Changes:
- Remove aiohttp.ClientTimeout(total=30) from ClientSession constructor
- Wrap the send operation in a nested async function (_do_send)
- Use asyncio.wait_for(_do_send(), timeout=30) for timeout handling
- Catch asyncio.TimeoutError explicitly and return clear error message
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on c07ef13

⚠️ Warnings

OSV vulnerability scan · View job

50 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 4m3s vs 6m25s (-36.9%). 7 job(s) slower, 14 faster, 2 unchanged.

  • Python tests / Run tests slice 10/12: +32.0s
  • Python tests / Run tests slice 8/12: +24.0s
  • Python tests / Run tests slice 3/12: -22.0s
  • Python tests / Run tests slice 1/12: +16.0s
  • Python tests / Run tests slice 2/12: -15.0s

@teknium1
teknium1 merged commit 358d550 into main Aug 7, 2026
43 checks passed
@teknium1
teknium1 deleted the fix/cron-sweep-salvage branch August 7, 2026 06:14
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cron Cron scheduler and job management comp/plugins Plugin system and bundled plugins platform/matrix Matrix adapter (E2EE) sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Aug 7, 2026
teknium1 added a commit that referenced this pull request Aug 7, 2026
Covers the behavior shipped in #80807 (background dispatch for
cronjob action='run') and #80838 (per-run '## Run Context' prompt,
gateway-loop delivery): immediate return with handle, completion
re-entering the conversation, in-flight dedupe, transient context
injection with prompt scanning, and the sync fallbacks.
POWERFULMOVES pushed a commit to POWERFULMOVES/PMOVES-hermes-agent that referenced this pull request Aug 10, 2026
Covers the behavior shipped in NousResearch#80807 (background dispatch for
cronjob action='run') and NousResearch#80838 (per-run '## Run Context' prompt,
gateway-loop delivery): immediate return with handle, completion
re-entering the conversation, in-flight dedupe, transient context
injection with prompt scanning, and the sync fallbacks.
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
Covers the behavior shipped in NousResearch#80807 (background dispatch for
cronjob action='run') and NousResearch#80838 (per-run '## Run Context' prompt,
gateway-loop delivery): immediate return with handle, completion
re-entering the conversation, in-flight dedupe, transient context
injection with prompt scanning, and the sync fallbacks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists platform/matrix Matrix adapter (E2EE) sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

4 participants