What isn't the dev agent's moves to nisse-core, unchanged in behaviour, with its tests: canonical, render, render_anthropic, llm, catalog, probe, context, views, state, reconcile, worker, cancel, dump, transport, matrix, execution, testing, vault, memory, oplog, envfile and gitea (whole). - nisse_core.state.StateStore holds the tables every agent has; an agent's subclass adds its tables (version, migrations), roles and views. nisse_dev.state.StateStore adds the build VM blocks (v5). - views.project takes what each role is shown, rather than a fixed table. - Vault takes the agent's name (agent=), for provenance. - A test that nisse_core never imports an agent. - The loop, config, git, delegation, expert, tools and evals stay in nisse-dev until nisse-ops has a loop to share. Docs: the Development Plan marks M7.1 done and notes that Phase 6 waits on the agent host and Terraform; Architecture Part L names the package. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
76 lines
2.5 KiB
Python
76 lines
2.5 KiB
Python
"""Check a model's declared context window against what its server does.
|
|
|
|
uv run python scripts/probe_context.py ALIAS [--config PATH]
|
|
|
|
ALIAS is a LiteLLM model alias. The LiteLLM URL and token come from the agent
|
|
config (NISSE_CONFIG, ./nisse-dev.yaml, or --config), with its secrets from
|
|
the environment or .env. See docs/Tuning-Guide.md, "Declaring a local model's
|
|
limits", and nisse_core/probe.py for what the verdicts mean.
|
|
"""
|
|
|
|
import argparse
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import httpx
|
|
|
|
from nisse_core.catalog import ModelCatalog
|
|
from nisse_core.envfile import load_env_file
|
|
from nisse_core.probe import probe
|
|
from nisse_dev.config import AgentConfig, ConfigError
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
|
parser.add_argument("alias", help="LiteLLM model alias to probe")
|
|
parser.add_argument("--config", help="agent config file to take LiteLLM from")
|
|
parser.add_argument(
|
|
"--max-probe-tokens",
|
|
type=int,
|
|
default=64_000,
|
|
help="refuse to send a prompt larger than this (default: %(default)s)",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
load_env_file(Path(os.environ.get("NISSE_ENV", ".env")).expanduser())
|
|
try:
|
|
config = (
|
|
AgentConfig.from_file(Path(args.config))
|
|
if args.config
|
|
else AgentConfig.load()
|
|
)
|
|
except ConfigError as exc:
|
|
print(exc, file=sys.stderr)
|
|
return 2
|
|
|
|
catalog = ModelCatalog.discover(config.llm_base_url, config.llm_token)
|
|
facts = catalog.facts(args.alias)
|
|
declared = facts.max_input_tokens
|
|
if declared is None:
|
|
print(
|
|
f"LiteLLM declares no max_input_tokens for {args.alias}; set one first",
|
|
file=sys.stderr,
|
|
)
|
|
return 1
|
|
if declared * 1.5 > args.max_probe_tokens:
|
|
print(
|
|
f"{args.alias} declares {declared} tokens; probing would send about "
|
|
f"{int(declared * 1.5)}. Raise --max-probe-tokens to allow it.",
|
|
file=sys.stderr,
|
|
)
|
|
return 1
|
|
|
|
with httpx.Client(
|
|
base_url=config.llm_base_url.rstrip("/"),
|
|
headers={"Authorization": f"Bearer {config.llm_token}"},
|
|
timeout=600,
|
|
) as http:
|
|
result = probe(http, args.alias, declared, facts.backing)
|
|
print(f"{args.alias}: {result.message}")
|
|
return 0 if result.verdict in ("matches", "refuses", "declared_conservative") else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|