feat(scheduler): enhance job configuration with reasoning effort, prefill messages, and provider routing
Added support for loading reasoning configuration, prefill messages, and provider routing from environment variables or config.yaml in the run_job function. This improves flexibility and customization for job execution, allowing for better control over agent behavior and message handling.
This commit is contained in:
parent
24f6a193e7
commit
5baae0df88
1 changed files with 44 additions and 0 deletions
|
|
@ -176,6 +176,8 @@ def run_job(job: dict) -> tuple[bool, str, str, Optional[str]]:
|
||||||
|
|
||||||
model = os.getenv("HERMES_MODEL") or os.getenv("LLM_MODEL") or "anthropic/claude-opus-4.6"
|
model = os.getenv("HERMES_MODEL") or os.getenv("LLM_MODEL") or "anthropic/claude-opus-4.6"
|
||||||
|
|
||||||
|
# Load config.yaml for model, reasoning, prefill, toolsets, provider routing
|
||||||
|
_cfg = {}
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
_cfg_path = str(_hermes_home / "config.yaml")
|
_cfg_path = str(_hermes_home / "config.yaml")
|
||||||
|
|
@ -190,6 +192,41 @@ def run_job(job: dict) -> tuple[bool, str, str, Optional[str]]:
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Reasoning config from env or config.yaml
|
||||||
|
reasoning_config = None
|
||||||
|
effort = os.getenv("HERMES_REASONING_EFFORT", "")
|
||||||
|
if not effort:
|
||||||
|
effort = str(_cfg.get("agent", {}).get("reasoning_effort", "")).strip()
|
||||||
|
if effort and effort.lower() != "none":
|
||||||
|
valid = ("xhigh", "high", "medium", "low", "minimal")
|
||||||
|
if effort.lower() in valid:
|
||||||
|
reasoning_config = {"enabled": True, "effort": effort.lower()}
|
||||||
|
elif effort.lower() == "none":
|
||||||
|
reasoning_config = {"enabled": False}
|
||||||
|
|
||||||
|
# Prefill messages from env or config.yaml
|
||||||
|
prefill_messages = None
|
||||||
|
prefill_file = os.getenv("HERMES_PREFILL_MESSAGES_FILE", "") or _cfg.get("prefill_messages_file", "")
|
||||||
|
if prefill_file:
|
||||||
|
import json as _json
|
||||||
|
pfpath = Path(prefill_file).expanduser()
|
||||||
|
if not pfpath.is_absolute():
|
||||||
|
pfpath = _hermes_home / pfpath
|
||||||
|
if pfpath.exists():
|
||||||
|
try:
|
||||||
|
with open(pfpath, "r", encoding="utf-8") as _pf:
|
||||||
|
prefill_messages = _json.load(_pf)
|
||||||
|
if not isinstance(prefill_messages, list):
|
||||||
|
prefill_messages = None
|
||||||
|
except Exception:
|
||||||
|
prefill_messages = None
|
||||||
|
|
||||||
|
# Max iterations
|
||||||
|
max_iterations = _cfg.get("agent", {}).get("max_turns") or _cfg.get("max_turns") or 90
|
||||||
|
|
||||||
|
# Provider routing
|
||||||
|
pr = _cfg.get("provider_routing", {})
|
||||||
|
|
||||||
from hermes_cli.runtime_provider import (
|
from hermes_cli.runtime_provider import (
|
||||||
resolve_runtime_provider,
|
resolve_runtime_provider,
|
||||||
format_runtime_provider_error,
|
format_runtime_provider_error,
|
||||||
|
|
@ -208,6 +245,13 @@ def run_job(job: dict) -> tuple[bool, str, str, Optional[str]]:
|
||||||
base_url=runtime.get("base_url"),
|
base_url=runtime.get("base_url"),
|
||||||
provider=runtime.get("provider"),
|
provider=runtime.get("provider"),
|
||||||
api_mode=runtime.get("api_mode"),
|
api_mode=runtime.get("api_mode"),
|
||||||
|
max_iterations=max_iterations,
|
||||||
|
reasoning_config=reasoning_config,
|
||||||
|
prefill_messages=prefill_messages,
|
||||||
|
providers_allowed=pr.get("only"),
|
||||||
|
providers_ignored=pr.get("ignore"),
|
||||||
|
providers_order=pr.get("order"),
|
||||||
|
provider_sort=pr.get("sort"),
|
||||||
quiet_mode=True,
|
quiet_mode=True,
|
||||||
session_id=f"cron_{job_id}_{_hermes_now().strftime('%Y%m%d_%H%M%S')}"
|
session_id=f"cron_{job_id}_{_hermes_now().strftime('%Y%m%d_%H%M%S')}"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue