Skip to content

About

Durable web research agent on Temporal in Python and TypeScript: parallel SpecStream searches ($1 per 1,000) and page reads as Markdown ($0.80 per 1,000), retried by Temporal without paying twice. Tested on the Temporal test server.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Durable web research with Temporal and SpecStream

A Temporal workflow, in Python and in TypeScript, that researches a question on the live web: it searches several angles at once with SpecStream, reads the best pages as Markdown, and returns them with their sources. Temporal makes it durable: when a worker stops between steps the workflow resumes where it was, and a search or a page read that finished is never paid again.

ResearchWorkflow(question, queries, max_pages)
  search(angle) x N, in parallel     POST /v1/web-search, fast tier    $1 per 1,000 searches
  read_pages(best URLs, question)    POST /v1/extract, up to 20 URLs  $0.80 per 1,000 pages read
  -> sources (url, title, snippet, published), pages (status, title, text), searches, cost_usd

A three angle question that reads five pages costs $0.003 for the searches and $0.004 for the pages.

Retries that never pay twice

SpecStream answers The activity Temporal
503 or 429 with Retry-After (calls for the minute used) waits as told and sends again, up to 4 times retries the activity after that, up to 5 attempts
401, 402, 403, 422 (refused key, empty balance, bad request) fails as non retryable, with SpecStream's code fails the workflow at once
a page read that times out after it was paid read_pages sends Idempotency-Key: <workflow id>:<activity id> on every attempt the retry gets the paid reply back from SpecStream

Python

cd python
pip install -r requirements.txt
temporal server start-dev                     # in another terminal, or point TEMPORAL_ADDRESS at Temporal Cloud
export SPECSTREAM_API_KEY=...                 # https://specstream.ai/workspace, $2 of credit with no card
python worker.py
python starter.py "What changed in the EU AI Act timeline?" "EU AI Act delay 2026" "AI Act GPAI obligations date"

activities.py, workflows.py, worker.py and starter.py, with the standard library SpecStream client in specstream_client.py.

TypeScript

cd typescript
npm install && npm run build
npm run worker
npm start "What changed in the EU AI Act timeline?" "EU AI Act delay 2026"

src/activities.ts calls SpecStream with fetch only; src/workflows.ts is the same workflow.

Test

cd python && python -m unittest discover -s tests -v
cd typescript && npm test                      # tsc, then node --test

Both run the workflow on Temporal's time skipping test server (downloaded on the first run; set TEMPORAL_TEST_SERVER_PATH to a downloaded binary to run offline) against a local stand-in for the SpecStream API. They check that each angle is searched once on the fast tier, that the best sources of each angle are interleaved and read in one call with the question as the query and a per activity Idempotency-Key, that sources with null title, snippet and date come through, that no sources means no read, that a 503 is waited out, that a blocked page comes back with no text, and that a refused key fails the workflow after one call. They need no key and spend nothing. Passed with temporalio 1.37.0 on Python 3.12 and the TypeScript SDK 1.27.0 on Node 22, with no network.

Prices

Price
Fast search (speed: "fast"), up to 10 results $1 per 1,000 searches, 937 ms median over 6,548 live calls in the 7 days to December 1, 2026
Default search, with a cited answer when the question has one $5 per 1,000 searches
Extract, a page read as Markdown $0.80 per 1,000 pages read
Free credit on sign up $2, which is 2,000 fast searches or 2,500 pages read, no card
Monthly Pro Pass $49 a month: 5,000 ready list rows a month and $49 of API credit

SpecStream is the live web data engine: first on WideSearch and 99 on SimpleQA Verified (benchmarks).

Links

License

MIT

About

Durable web research agent on Temporal in Python and TypeScript: parallel SpecStream searches ($1 per 1,000) and page reads as Markdown ($0.80 per 1,000), retried by Temporal without paying twice. Tested on the Temporal test server.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages