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.
npx agentmods add agents/netmindai-open/narranexus/social_network.pygit clone --depth 1 https://github.com/NetMindAI-Open/NarraNexusWrote 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.
[](https://agentmods.dev/agents/netmindai-open/narranexus/social_network.py)<a href="https://agentmods.dev/agents/netmindai-open/narranexus/social_network.py"><img src="https://agentmods.dev/badge/agents/netmindai-open/narranexus/social_network.py.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00801 |
| Opus 5 | $0.00000 | $0.00400 |
| Sonnet 5 | $0.00000 | $0.00160 |
| Haiku 4.5 | $0.00000 | $0.00080 |
Grade A, and why
social_network.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.
What it actually says
2026-06-08 — entity endpoints route through the repo
Both endpoints now go through SocialNetworkRepository (reading memory_entity) plus an _entity_to_info helper, instead of touching instance_social_entities. Behaviour for callers is unchanged; only the storage source moved.
agents/social_network.py — 社交网络实体查询路由
为什么存在
SocialNetworkModule 维护 Agent 认识的人/组织的档案,存储在 instance_social_entities 表。这个路由暴露三个只读接口:查询单个实体的详细信息、列出所有实体、关键词/语义搜索。这些接口服务于前端的社交网络面板,以及开发者调试社交记忆的需求。
上下游关系
- 被谁用:
backend/routes/agents/core.py聚合;前端社交网络面板 - 依赖谁:
InstanceRepository— 查询SocialNetworkModule实例 IDSocialNetworkRepository— 语义搜索(semantic_search)和关键词搜索(keyword_search)- (历史:语义搜索曾经由 agent_framework 的 embedding 工具生成 query 向量;该向量化子系统已整体移除)
xyz_agent_context.utils.db.db_factory.get_db_client— 直接查询instance_social_entities表
设计决策
路由注册顺序
/{agent_id}/social-network/search 必须在 /{agent_id}/social-network/{user_id} 之前注册,否则路径匹配时 "search" 会被当成 user_id 的字符串值,把搜索请求路由到单实体查询接口,导致查不到结果但也不报错。注释里专门标注了这个要求。FastAPI 在同一路由器内按注册顺序匹配,不按路径特异性排序。
硬限 1000 条
get_all_social_network_entities 用 limit=1000 硬限制最大返回数量。对于正常使用场景(Agent 通过日常对话积累的社交关系,通常是几十到几百条)这够用,但如果一个 Agent 接入了大型通讯录,1000 条可能不够。目前没有分页接口。
语义搜索即时 embedding
搜索时调用 get_embedding(query) 实时生成向量,这会产生一次 LLM API 调用(embedding 接口)。如果 embedding 服务不可用,语义搜索会抛异常,前端需要处理。关键词搜索不依赖外部服务,更稳定。
Gotcha / 边界情况
- 只查第一个实例:如果一个 Agent 有多个
SocialNetworkModule实例(理论上可能,虽然实践中通常只有一个),这里只用instances[0]的实例 ID。其他实例的社交实体不会被查询到。 _parse_json处理双重编码:代码里有处理 JSON 双重编码的逻辑(json.loads结果如果还是字符串,再json.loads一次)。这说明历史数据里存在identity_info等 JSON 字段被双重序列化的情况,是历史遗留问题。
新人易踩的坑
单实体查询接口用 user_id 作为路径参数,但实际上查的是 entity_id 字段(WHERE entity_id = {user_id})。这个接口的命名继承自最初只处理"用户"类型实体的设计,实际上 entity_id 可以是任何类型实体的 ID,不限于用户。
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.
- 4d ago First seen · 48 lines · 0 tokens per session scan A 8d43a2433557
social_network.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 801 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.
Other agents, from other repositories
cpp-reviewer
Expert C++ code reviewer specializing in memory safety, modern C++ idioms, concurrency, and performance. Use for all C++ code changes. MUST BE USED for C++ projects.
context
You are the Context agent. Your job is memory and context-window management: decide what to keep, compact, or recall so the working context stays high-signal and within budget.
note-scorer
Batch note quality scorer for the Obsidian vault. Reads notes, applies promote-gate scoring mode, returns structured scores and action recommendations.
portable-memory-parent-orchestrator
Top orchestrator for the portable-process-memory feature. Delegates to sync-transport (push/fetch folded into the verbs, plain-git, credential inheritance, offline-fail-safe) and event-fold (ownership events + the fail-closed divergence tripwire in the gate fold). Architect-only; coordinates portability/transport work…
context
Agent "context" from hannsxpeter/godpowers, covering scope, context, decisions, rules and workflows.
neon-drizzle-expert
Expert in Neon PostgreSQL (v17), Drizzle ORM (v0.44.4), and Zod (v4.0.17) schema validation for production memory systems. Specializes in serverless PostgreSQL patterns with @neondatabase/serverless (v1.0.1), type-safe database operations, and migration strategies.