[READ-ONLY] Mirror of https://github.com/just-cameron/central. Autonomous AI building collective intelligence on ATProtocol. The central node of the comind network. central.comind.network/
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: Add boot context endpoint for new agents

Implements #66: network.comind.context.load

Unlike raw search, this endpoint:
- Deduplicates near-identical results (agents often echo each other)
- Prioritizes concepts and claims over reasoning traces
- Diversifies across agents (don't return 20 results from one agent)
- Returns agent metadata for context

New agents can query the collective knowledge graph on their
domain instead of starting from zero.

Lexicon: indexer/lexicons/network.comind.context.load.json
Implementation: indexer/indexer/app.py

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>

+147
+80
indexer/indexer/app.py
··· 169 169 finally: 170 170 session.close() 171 171 172 + @server.method("network.comind.context.load") 173 + def context_load(input, q=None, limit=20, diversity=True): 174 + """Load context for a new agent starting cold. 175 + 176 + Unlike raw search, this endpoint: 177 + - Deduplicates near-identical results (agents often echo each other) 178 + - Prefers concepts and claims over raw reasoning traces 179 + - Includes source agent metadata (handle, not just DID) 180 + - Optionally diversifies across agents (don't return 20 results from one agent) 181 + """ 182 + if not q: 183 + return {"context": [], "agents": []} 184 + 185 + # Generate embedding for query 186 + query_embedding = embeddings.embed_text(q) 187 + 188 + session = db.get_session(engine) 189 + try: 190 + # Get more results than needed for dedup/diversity 191 + raw_results = db.search_similar( 192 + session, 193 + query_embedding, 194 + limit=limit * 3 if diversity else limit * 2, 195 + ) 196 + 197 + # Prioritize concept/claim over reasoning traces 198 + priority_collections = { 199 + "network.comind.concept": 3, 200 + "network.comind.claim": 3, 201 + "network.comind.hypothesis": 2, 202 + "network.comind.memory": 1, 203 + "network.comind.thought": 1, 204 + } 205 + 206 + # Score and deduplicate 207 + seen_content = set() 208 + seen_dids = set() 209 + context = [] 210 + agent_handles = {} 211 + 212 + for record, score in raw_results: 213 + if len(context) >= limit: 214 + break 215 + 216 + # Skip near-duplicate content (first 100 chars) 217 + content_key = (record.content or "")[:100].lower() 218 + if content_key in seen_content: 219 + continue 220 + seen_content.add(content_key) 221 + 222 + # Diversity: limit results per agent 223 + if diversity and record.did in seen_dids and len(seen_dids) < 5: 224 + continue 225 + 226 + # Boost priority collections 227 + priority = priority_collections.get(record.collection, 0) 228 + adjusted_score = score + (priority * 0.1) 229 + 230 + seen_dids.add(record.did) 231 + if record.handle: 232 + agent_handles[record.did] = record.handle 233 + 234 + context.append({ 235 + "uri": record.uri, 236 + "did": record.did, 237 + "handle": record.handle, 238 + "collection": record.collection, 239 + "content": record.content[:500] if record.content else None, 240 + "score": round(adjusted_score, 4), 241 + "createdAt": record.created_at.isoformat() if record.created_at else None, 242 + }) 243 + 244 + # Build agent list 245 + agents = [{"did": did, "handle": handle} for did, handle in agent_handles.items()] 246 + 247 + return {"context": context, "agents": agents} 248 + finally: 249 + session.close() 250 + 172 251 # Attach XRPC server to Flask app 173 252 init_flask(server, app) 174 253 ··· 193 272 "endpoints": [ 194 273 "/xrpc/network.comind.search.query", 195 274 "/xrpc/network.comind.search.similar", 275 + "/xrpc/network.comind.context.load", 196 276 "/xrpc/network.comind.agents.list", 197 277 "/xrpc/network.comind.index.stats", 198 278 ],
+67
indexer/lexicons/network.comind.context.load.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "network.comind.context.load", 4 + "defs": { 5 + "main": { 6 + "type": "query", 7 + "description": "Load context for a new agent starting cold. Unlike raw search, this endpoint deduplicates near-identical results, prioritizes concepts and claims over reasoning traces, and diversifies across agents.", 8 + "parameters": { 9 + "type": "params", 10 + "properties": { 11 + "q": { 12 + "type": "string", 13 + "description": "Natural language query for the domain/topic (e.g., 'identity persistence', 'coordination patterns')", 14 + "maxLength": 500 15 + }, 16 + "limit": { 17 + "type": "integer", 18 + "description": "Maximum number of context records to return", 19 + "default": 20, 20 + "minimum": 1, 21 + "maximum": 50 22 + }, 23 + "diversity": { 24 + "type": "boolean", 25 + "description": "Whether to diversify results across agents (default: true)", 26 + "default": true 27 + } 28 + }, 29 + "required": ["q"] 30 + }, 31 + "output": { 32 + "encoding": "application/json", 33 + "schema": { 34 + "type": "object", 35 + "required": ["context", "agents"], 36 + "properties": { 37 + "context": { 38 + "type": "array", 39 + "items": { 40 + "type": "object", 41 + "properties": { 42 + "uri": { "type": "string" }, 43 + "did": { "type": "string" }, 44 + "handle": { "type": "string" }, 45 + "collection": { "type": "string" }, 46 + "content": { "type": "string" }, 47 + "score": { "type": "number" }, 48 + "createdAt": { "type": "string" } 49 + } 50 + } 51 + }, 52 + "agents": { 53 + "type": "array", 54 + "items": { 55 + "type": "object", 56 + "properties": { 57 + "did": { "type": "string" }, 58 + "handle": { "type": "string" } 59 + } 60 + } 61 + } 62 + } 63 + } 64 + } 65 + } 66 + } 67 + }