llm_config.py

llm_config.py is an agent for coding agents from NetMindAI-Open/NarraNexus. It costs 0 tokens per session (1,609 once invoked), scanned A, original, Apache-2.0.

An agent component that reports whether a free usage allowance is currently locking the agent to a particular language model.

In plain words
What is it for?
It supports the agent model settings screen by showing the active free-tier model and whether model switching is currently effective.
Why use it?
It prevents the interface from suggesting that a model choice worked when the free allowance will override it at runtime.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/netmindai-open/narranexus/llm_config.py
Clone the repo
git clone --depth 1 https://github.com/NetMindAI-Open/NarraNexus

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for llm_config.py

README.md
[![agentmods](https://agentmods.dev/badge/agents/netmindai-open/narranexus/llm_config.py.svg)](https://agentmods.dev/agents/netmindai-open/narranexus/llm_config.py)
Your own site
<a href="https://agentmods.dev/agents/netmindai-open/narranexus/llm_config.py"><img src="https://agentmods.dev/badge/agents/netmindai-open/narranexus/llm_config.py.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,609 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01609
Opus 5 $0.00000 $0.00805
Sonnet 5 $0.00000 $0.00322
Haiku 4.5 $0.00000 $0.00161

Measured 4d ago against content hash 3aaa9b6b0141, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

llm_config.py scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.mindflow/mirror/backend/routes/agents/llm_config.py.md · 96 lines

How it starts

The opening of the file, as written. The whole thing — 96 lines — stays where its author put it; the contents beside it link to each section on GitHub.

2026-07-28 — 不再返回 free_tier 锁块

GET 响应里的 free_tier: {active, model} 块删除。免费额度是普通 provider 卡,per-agent override 不会被任何东西抢占,composer 的模型 chip 永远是可用 控件 —— 继续下发一个恒为 inactive 的锁块,只会诱导前端渲染一种不可能发生的 状态。

2026-07-23 — GET 响应新增 free_tier 锁定块(诚实化模型选择器)

GET /{agent_id}/llm-configdata 增加 free_tier: {active, model}。动机: 云端免费额度优先策略([[resolver]] 的 SYSTEM_OK 分支)在免费额度有余额时 忽略 per-agent override、锁死系统固定模型——底部 [[ComposerModelBadge]] 却照常 显示可切下拉、写库、乐观更新,用户以为切成功了实则运行时永远没变。这是测试同学报的 "model 选择器切换不生效" 的真根因(不是前端/写库 bug)。

free_tier 由单点 free_tier_lock_for(user_id, sys_svc, quota_svc, db) ([[resolver]])算出——路由只负责从 request.app.state 取 system_provider / quota_service(可能为 None)并连同 db 传进去;resolver 组装 + 是否锁定 + model 提取全在 provider_resolver 单点完成(review 抓出第一版把 helper 复制进了 llm-config 和 quota 两个 路由,本次收敛)。active 语义 = SYSTEM_OK 门;model 是锁定时真正运行的系统 agent 模型。本地模式两服务为 None → active=False,前端行为与改前完全一致(切换保持可用)。

前端据此:徽章渲染只读 free tier · <model> chip(优先于其它状态), [[AgentLlmConfigPanel]] 顶部加诚实 banner(控件仍可编辑,允许预配置,额度耗尽即生效)。 决策背景:Owner 选了"UI 诚实化、免费期锁单模型",不改 free-tier-first 运行时策略本身。 测试见 test_agents_llm_config_routes.py 新增三例(未 wire 服务→inactive / 有余额→ 锁定系统模型 / 余额耗尽→inactive)。

2026-07-18 — 路由级门禁删除,策略随 set_agent_slot 下沉 cloud_policy

昨天加的内联 netmind-only 检查块(含它的 prov 查询)整体删除:PUT 现在把 actor_is_staff=_is_staff(request) 传给 set_agent_slot,策略(provider 来源 + per-agent 框架钉选门禁,后者是新增的——云端非 staff 不得钉与 owner 默认不同的框架,堵住框架切换 staff-gate 的侧门)在服务层由 [[cloud_policy]] 统一强制;路由 catch CloudPolicyViolation → 403。is_cloud_mode import 随之移除。

2026-07-17 — 云端门禁从 OAuth-only 扩宽为 netmind-only

PUT 的云端非 staff 门禁从 source in _OAUTH_SOURCES(拒 OAuth 卡)改为 source != "netmind"(只许 NetMind 卡)——产品决策:云端只能用 NetMind 账户 运行,自有 API key 是本地版功能。旧 OAuth 拦截被包含(OAuth 源都非 netmind),_OAUTH_SOURCES 常量随之删除。与 providers.py 的 _netmind_slots_only 同一规则(那边守用户级槽 + onboard/add);staff 豁免、 本地不受影响。前端 [[AgentLlmConfigPanel]] 同步过滤下拉。测试见 test_agents_llm_config_routes.py 新增三例(403 / netmind 通过 / staff 绕过)。

2026-07-09 (review fixes) — raw owner rows + deployment_mode + owner-scoped gate

Read the full file on GitHub · 96 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 96 lines · 0 tokens per session scan A 3aaa9b6b0141

Subscribe to this mod's changes

llm_config.py is an agent published in the GitHub repository NetMindAI-Open/NarraNexus (85 stars, last pushed yesterday), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,609 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.