Skip to content

Add cron_effort to run cron/hook turns below interactive effort#163

Open
alex-fedotyev wants to merge 1 commit into
ClickHouse:mainfrom
alex-fedotyev:alex/cron-effort
Open

Add cron_effort to run cron/hook turns below interactive effort#163
alex-fedotyev wants to merge 1 commit into
ClickHouse:mainfrom
alex-fedotyev:alex/cron-effort

Conversation

@alex-fedotyev

Copy link
Copy Markdown
Contributor

Summary

Cron- and hook-sourced turns are sensing and triage work that fire far more
often than interactive sessions and rarely need the interactive model's full
reasoning depth. Today they inherit the global agent.effort (default max),
so a high-frequency job like the watcher pays top-tier effort on every quiet
tick, which is the dominant per-turn cost on those jobs.

This adds agent.cron_effort (default medium) and applies it in
_build_options: a turn whose source is cron or hook uses cron_effort,
while interactive sources (web, telegram, wakeup) keep effort. The
selected value still flows through _effective_effort, so it is clamped to the
target model's effort ladder and stays safe on models with a shorter ladder.

The source-to-effort choice is factored into a small
_base_effort_for_source staticmethod so the policy is unit-testable in
isolation, mirroring the existing _effective_effort helper.

No migration needed: cron_effort defaults to medium, and a deployment that
wants the previous behavior can set cron_effort: max.

Test plan

  • New unit tests in tests/test_engine.py:
    • test_base_effort_for_source: cron/hook map to cron_effort;
      web/telegram/wakeup/api map to effort.
    • test_base_effort_for_source_then_capped: routing composed with the
      model-cap clamp (Sonnet ladder, and pass-through for an uncapped model).
    • test_agent_config_cron_effort_default_and_override: from_dict default
      is medium, override respected, effort stays independent.
  • python3 -m pytest tests/ -> 1355 passed, 2 skipped. The only 2 failures
    are pre-existing and unrelated (docker-mode detection tests that assume the
    host is not a container); they fail identically on main.

Cron- and hook-sourced turns are sensing and triage work that fire far
more often than interactive sessions and rarely need Opus-tier
deliberation. They previously inherited the global agent.effort (max),
which is the dominant per-turn cost on high-frequency crons such as the
watcher.

Add AgentConfig.cron_effort (default medium) and apply it in
_build_options through a new _base_effort_for_source helper: a turn whose
source is "cron" or "hook" uses cron_effort, everything else keeps
effort. The chosen value still passes through _effective_effort for
model-cap clamping, so it is safe on models with a shorter effort ladder.

Interactive sources (web, telegram, wakeup) are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant