Back to case studies

Demandfarm: Account Research Agent

Project:Demandfarm
Period: 2024
Outcome: Replaced 1 to 3 hours of manual research per account with one API call that returns a structured account brief in 10 to 60 seconds
Stack:PythonPortkey AI GatewaySEC APIYahoo Finance APIGoogle SearchAWSPostgreSQLThreadPoolExecutorREST API

Organization: Demandfarm (Key Account Management software for B2B)
Role: Architect & builder
Period: 2024
Stack: Python, Portkey AI Gateway, SEC API, Yahoo Finance API, Google Search, AWS Cloud, PostgreSQL, REST API, ThreadPoolExecutor

The problem

Demandfarm sells Key Account Management software to enterprise B2B teams. Their users are key account managers and sales leaders managing strategic existing accounts, not SDRs prospecting cold lists.

Before any strategic account meeting, a KAM needs to know what the account is doing financially: latest earnings, year-over-year trends, recent leadership changes, competitive moves, strategic priorities from the CEO's commentary. The information exists publicly (SEC filings, earnings call transcripts, annual reports, financial news), but reading and synthesizing it for one account takes hours. At enterprise volume, the math does not work.

Demandfarm wanted an agent built into their platform that would automate this research and produce a digestible report for each account.

What I built

A REST-API account intelligence agent with two specialized data collectors and an LLM synthesis layer.

Public Company Data Collector

For listed companies. Input: a ticker symbol (the agent first resolves the official ticker from the CRM-provided account name, since the CRM name is often inaccurate). Collects in parallel:

  • Yahoo Finance API for basic info, news, financials, balance sheet, cash flow
  • SEC API for regulatory filings and annual reports
  • Google Search for annual reports and earnings call transcripts not exposed via the structured APIs
  • Portkey Chat API for LLM analysis of annual reports and earnings call transcripts

Output: a structured dictionary with basic info, news, financials, balance sheet, cash flow, annual report extracts, earnings call summary, and value-proposition alignment.

Private Company Data Collector

For non-listed companies. Input: a company domain. Collects from the company website plus LLM analysis:

  • CEO information
  • Funding rounds and latest funding details
  • Lingo map (the company's specific terminology)
  • Analyzed website content (growth and focus areas)
  • Similar companies
  • Customers
  • Ideal customer profile
  • Employee count

LLM Synthesis Layer

Both collectors feed a synthesis step (via Portkey Chat API) that produces five output sections:

  • A. Firmographics. Official name, business type, industry, sub-industry, HQ, regional offices, ownership status, parent and subsidiaries, financial performance, funding, leadership, founders, target market, key customers, market position, product lines, milestones
  • B. Recent News. Key developments, financial updates, leadership changes, market trends, PR and CSR activities, challenges and controversies
  • C. Top Competitors. Identification, competitive analysis (strengths, weaknesses, market share, positioning), product and service comparison, recent activities
  • D. Summarized Reports synthesized from earnings reports and earnings call transcripts. Strategic goals, performance highlights, market outlook, quarterly results, management commentary, future guidance
  • E. Aligned Value Proposition. Maps the user's organization's value proposition to the target account's strategic priorities and pain points, producing a contextualized recommendation

The engineering that made it ship

Portkey AI Gateway. Every LLM call routes through Portkey. Lets us switch providers (Claude, GPT, open-source) without changing call sites, externalize prompt templates, get observability and logging out of the box. Critical for a long-lived API that needs to evolve model choice without redeploying.

Parallel collection with ThreadPoolExecutor. Each data source has its own latency profile (SEC API is slow, Yahoo is fast, Google Search is medium). Sequential collection would take 30+ seconds per account. Parallel fan-out brings it under 10s for the public collector.

Database UPSERT with 2-week TTL. Account research is expensive to generate. Cached results live for 2 weeks. Re-requests within that window serve from cache. After 2 weeks, the next request triggers a refresh. Refresh is PULL-based (on next request), not automatic, which keeps infrastructure cost bounded.

Async job interface. Account research takes 10 to 60 seconds depending on data sources. Synchronous REST would tie up client connections. The API uses a job-token pattern: submit a request, get a token, poll the token endpoint or receive a webhook on completion.

Credit-based rate limiting. Each customer has a credit balance with expiry (for example, 100 credits valid until a specific date). Each account research is 1 credit. Rate limit is per-customer, capped at 5 calls per minute. Audit logging captures every REST invocation for billing and debugging.

Company name resolution. CRM-stored account names are often informal or incorrect. The agent has a name-resolution step that disambiguates the official ticker symbol and long name from a fuzzy input. Handles edge cases like Nestle (multinational with regional listings) and ambiguous small-caps.

Multi-market ticker coverage. Tested across NYSE, NASDAQ, Euronext, LSE, SZSE, TSX, BSE, ASX. The agent picks the appropriate market based on the input or surfaces ambiguity.

The outcome

The agent replaced 1 to 3 hours of manual KAM research per account with a single API call returning a structured report in 10 to 60 seconds, running in production with caching, credit-based rate limiting, and full audit logging.

Key takeaways

The pattern that makes research agents reliable in production is deterministic scaffolding around the LLM: fuzzy entity disambiguation, parallel data collection, structured output synthesis, pull-based TTL caching, rate limiting, and gateway observability.