Hi, I’m Khalid. I built a tiny-but-mighty side project I’m calling SparseContext, an AI agent that researches companies, accounts, and business processes, then produces a crisp and verifiable research brief. Think fewer tabs, more insight, and a little bit of personality. It finds signals across public sources, prioritizes recency, normalizes details into a consistent JSON contract, and keeps links for verification.

This page is the story and the route. Ship first, polish later. If you’re at Cohere: yes, I’m absolutely the person who lovingly over-engineers side projects for fun. Also yes, I’m forward-deployable and bring snacks.

What is SparseContext?

An autonomous agent named “B2B Context Researcher” that:

  • Accepts a single target input (company name, account, or business process)
  • Scours multiple sources (news, press releases, job postings, tech blogs, filings, social)
  • Extracts and structures context into a stable JSON contract
  • Prioritizes the last 12 months
  • Iteratively refines when new sources pop up
  • Returns concise, factual, actionable briefs with links

The output contract

{
  "company_overview": {"size": "", "industry": "", "key_executives": []},
  "business_model_and_customers": {"products_services": [], "customer_segments": []},
  "technology_or_process_stack": {"platforms": [], "integrations": [], "tools": []},
  "recent_changes_or_signals": [
    {"type": "acquisition|leadership|layoffs|partnership|compliance", "detail": "", "source": ""}
  ],
  "pain_points_and_challenges": [""],
  "opportunities_for_engagement": [""],
  "generated_at": "2025-09-16T00:00:00Z"
}

Why Cohere?

  • Model quality: Command models are practical and controllable for production agents.
  • Enterprise reality: Aya, RAG, and observability patterns that play nice with real infra.
  • Multimodal runway: Text + vision unlocks reading screenshots of dashboards, slideware, filings.

I like building things that are boring to operate and exciting to use. Cohere leans into both.

System prompt and DSPy

SparseContext is driven by a clear system prompt and compiled with DSPy so the behavior is consistent and measurable. The system prompt defines responsibilities, constraints, and output shape, while DSPy turns that into a program with signatures and objectives.

  • Accept a single target input such as a company, account, or business process
  • Gather context from news, press releases, job postings, tech blogs, filings, and social signals
  • Extract and normalize findings into a strict JSON schema
  • Prioritize information from the past 12 months
  • Cite source links next to each claim for verification
  • Iterate if new or better sources appear during the run
  • Keep output concise, factual, and actionable

What it does, step by step

  1. Ingest: fetch and cache candidate sources for the target
  2. Triage: rerank and deduplicate to keep only credible and recent items
  3. Extract: use the system prompt to fill the schema fields with grounded facts
  4. Verify: attach URLs to each claim and drop anything not attributable
  5. Refine: if gaps remain, expand the search window or sources and repeat

System sketch

  • Router: You are here at the Hugo route /hackthenorthagent/.
  • Agent runtime: A small service (Node/TypeScript or Python) with a task loop.
  • Retrieval: Source plugins (news, SEC/SEDAR, careers, tech blogs) + lightweight dedup.
  • LLM: Cohere Command for reasoning and JSON-mode generation; reranking for source triage.
  • Multimodal: Screenshot OCR for PDFs/slide decks, image-to-text for charts.
  • Storage: Ephemeral cache + signed URLs to raw sources for verification.

Architecture diagram

               +---------------------------+
               |        Client / API       |
               |  POST /sparsecontext/run  |
               +--------------+------------+
                              |
                              v
                +-------------+--------------+
                |   Task Orchestrator        |
                |  queue, retries, tracing   |
                +------+------+--------------+
                       |      |
                fetch sources  | compile system prompt
                       |      |
                       v      v
          +------------+------+-------------+
          |       Retrieval Plugins         |
          | news, filings, jobs, blogs, X   |
          +------------+------+-------------+
                       |
                 deduplicate, rerank
                       |
                       v
                +------+--------------------+
                | Cohere + DSPy Program     |
                | system prompt, signatures |
                | JSON mode, schema checks  |
                +------+--------------------+
                       |
                  verified JSON
                       |
                       v
              +--------+----------------+
              | Response + Source Links |
              +-------------------------+

Pseudo-API design (Node/Express flavor)

import express from "express";
import { cohereClient } from "./cohere";
import { collectSources } from "./sources";
import { enforceSchema } from "./schema";

const app = express();
app.use(express.json());

app.post("/sparsecontext/run", async (req, res) => {
  const { target } = req.body;
  if (!target) return res.status(400).json({ error: "missing target" });

  const sources = await collectSources(target, { windowMonths: 12 });

  const systemPrompt = `You are B2B Context Researcher. Produce strict JSON.\nTarget: ${target}\nSources:${sources.map(s => `\n- ${s.title} (${s.url})`).join("")}`;

  const co = await cohereClient();
  const resp = await co.chat({ model: "command-r-plus", message: systemPrompt, temperature: 0.2 });

  const json = enforceSchema(resp.text);
  return res.json({ target, json, sources });
});

app.listen(8787);

Tiny Python version (FastAPI)

from fastapi import FastAPI
from pydantic import BaseModel

class RunReq(BaseModel):
    target: str

app = FastAPI()

@app.post("/sparsecontext/run")
def run(req: RunReq):
    # collect_sources + cohere call + schema enforcement
    return {"ok": True, "target": req.target}

DSPy sketch (compiling the system prompt)

import os
import dspy

# Define the desired IO using a Signature
class ResearchBrief(dspy.Signature):
    """Produce a structured B2B research brief with citations."""
    target = dspy.InputField()
    sources = dspy.InputField()
    json_brief = dspy.OutputField()

# Configure Cohere as the LM backend
cohere_lm = dspy.Cohere(model="command-r-plus", api_key=os.environ["COHERE_API_KEY"])  # type: ignore
dspy.configure(lm=cohere_lm)

# Compile a program that optimizes the system prompt to maximize schema coverage
program = dspy.Program(ResearchBrief)

def run_brief(target: str, sources: list[dict]):
    result = program(target=target, sources=sources)
    return result.json_brief

Business use cases

  • Account Research at Scale: SDRs get 1-page briefs with verified links, not vibes.
  • Post-Earnings Changes: Surfacing product realignments, layoffs, or GTM pivots within 24h.
  • Tech Mapping: Identify CRM, data tools, and integration surface area for solutioning.
  • Process Audits: Map purchasing, risk, compliance changes for enterprise onboarding.

If you’ve ever tried to do this manually at 50+ accounts a week… my condolences. SparseContext automates the first 85% so humans can do the last 15% (judgment and outreach).

A note on scale (and cost)

  • Bottleneck: Crawling and dedup > LLM tokens. Use per-source caps and caching.
  • JSON strictness: Use function-calling/JSON mode to avoid hallucinated keys.
  • Cold starts: Keep one warm worker; batch fetches; backpressure via queue depth.
  • Observability: Log missing fields, source failures, and schema diffs per run.

With sane guardrails, a single modest node can serve hundreds of briefs/hour. If we need to go bigger: shard by target initial, push heavy fetch to workers, and keep the LLM on a predictable budget. I am small but mighty. Like a well-caffeinated hamster with Kubernetes.

Fun bits

  • I name my queues after Pokémon, because you should fear a backlog called “Gengar”.
  • I once optimized a pipeline so hard it became emotionally distant. Worth it.
  • If this made you smile, we should probably ship something together.

Ship checklist (for Cursor deploy)

  • Define the JSON contract
  • Write the system prompt
  • Sketch the endpoints
  • Make this route live (/hackthenorthagent/)
  • Add DSPy program scaffold
  • Wire real source collectors
  • Add Cohere client + API key plumbing
  • Enforce JSON schema strictly

If you’re at Cohere and want a walkthrough, ping me. I will bring a whiteboard marker and a mildly unhinged diagram. Cheers!