Repository navigation
The ingest CLI and the Python SDK upload files for the server's extractor to parse - #280
Merged
Merged
Conversation
…ctor to parse Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e plain errors Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ords where its bytes came from Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ts absolute path Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ploaded as written Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e the demo resolves Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…type Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
This was referenced Nov 6, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #157
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
dev/loom_ingest.pyuploads a file's bytes and ingests them withknowledge.ingest, so the server's extractor parses every format and the CLI waits for the job and prints the revision it published; its--upsertflag is removed (every ingest publishes the source's next revision).loom demoingests its file the same way. The Python SDK gainsknowledge.upload,ingest,ingest_status,ingest_cancel,wait_for_ingestandingest_file.Why
The issue's plan moves every client onto the upload and ingest path: originals are uploaded as they are, "extraction runs in a separate sandboxed service", and client-side extraction is removed. The ingest CLI still parsed PDFs with pypdf and HTML with trafilatura on the operator's machine and posted the text through
knowledge.add, so a file it ingested had no original, no revision from an extraction, no locators and none of the extractor's coverage or warnings.loom demoloaded that script to reuse its parse step and posted the text toknowledge.upsert. The Python SDK had no way to send a file: a caller wrote the two HTTP steps by hand.Design
sdk/python/loom/knowledge.py):upload(data, filename, content_type=)posts the raw bytes to/v1/knowledge.uploadwith theirsha256.ingest(upload_id, source_uri=, ...)takesknowledge.ingest's fields.ingest_statusandingest_cancelwrap the two ops.wait_for_ingest(ingestion_id, timeout_s=600, poll_s=1)polls until the job isready,partial,failedorcancelled. Past the timeout it raisesTimeoutError, naming the state the job is still in.ingest_file(path, wait=True, ...)runs all three for a local file. It reads the file off the event loop, and names the document as the CLI does:file://<absolute path>, titled by the file's name less its extension.Transport.requestgains acontentargument, sent asapplication/octet-stream. The upload route is outside the op registry. A request there is still not retried, but a429(which the server answers before doing anything: an upload it refuses stores nothing) is now resent after the server'sRetry-Afterwithinratelimit_max_wait_s, as an op is. The old CLI path had that pacing throughknowledge.add, so a run over an S3 prefix keeps it. The wait is one helper (_rate_limit_wait) the op path andrequestshare.dev/loom_ingest.py):indexfor none, never the host), and for a name with no extension the response's media type names the format.error_codeand message.--no-wait,--timeout,--format(the ingest option) and--allow-partial.get_object, so an object with no extension (listed under a prefix: a key with no extension is one) is named by its stored media type, as a URL is.--dry-runprints the file's size, itssha256and the ingest fields.--upsert.loom demo(server/cli/demo.py): it uploadsAGENTS.md(or--file) through a new raw-body seam (server/cli/_client.py::post_bytes), ingests it with the same fields the CLI sends (ingested_fromincluded), and pollsknowledge.ingest_statusfor up to two minutes (it stops at once for a job the server cannot find). It prints the revision, chunks and format, or why the job failed: aformat_unavailablefailure points atloom upand its reference extractor, and a job still pending names the worker that runs it. It no longer loadsdev/loom_ingest.py, so it needs onlyAGENTS.md.--rootnow names where that file is (the cwd, then the package's checkout, by default).ingestextra keeps onlyboto3(the S3 fetch).pypdfandtrafilaturaleave it, anduv.locklosestrafilaturaand the packages only it needed (removals only: the lock keepsmain's revision, anduv lock --checkpasses with the uv CI pins); the extractor service still declares its own parsers.loom demouploads and ingests its file. The ingest CLI section ofdocs/features/knowledge.mdnow says the CLI uploads what it is given and parses nothing. A paragraph on the SDK helpers follows the ingest steps.ingestextra's row in the local-development page is updated.Alternatives considered:
ingestcommand on the shippedloomCLI. That is a new command surface; the dev script is whatmake ingestand the docs already name.Scope and risk
loom demoand the Python SDK): no op, table, migration or setting changes.loom demosends failsformat_unavailable, where the old path posted the text it parsed; both print the code. A text file posted withknowledge.addstill works without one.loom demoalso needs the ingest worker running, which the stock stack runs.--upsertis gone, and the operator sees an argparse error if they pass it. Every ingest publishes the next revision of the source, which is what--upsertdid.Compatibility, rollout and rollback
/v1/knowledge.uploadand the ingest ops, which a server must serve. Against an older server they get a404, which the SDK raises asNotFoundError.pip install '.[ingest]'still bringsboto3for S3 sources.Tests
tests/unit/test_sdk_knowledge_ingest.py(9 tests):sha256, the octet-stream type and the bearer;429refused is sent again after its hint, and past the pacing budget it raisesRateLimited;wait_for_ingestreturns at once for a job the server cannot find;ingestsends every field;wait_for_ingestpolls until the job ends and times out with the state the job is still in;ingest_filenames the document by its path, or bysource_uri, titles it by the file's stem, and waits or not;tests/unit/test_loom_ingest.py, rewritten (28 tests):--source-uri,--title,--formatand--allow-partialreach the ingest;--no-waitpolls nothing;--timeoutfails it, a job the server cannot find is reported as not found, and a partial one counts as ingested;index, and an oversize URL is refused;--dry-runsends nothing;tests/unit/test_cli_demo.py, rewritten for the new path (20 tests, the ingest body'singested_fromchecked):AGENTS.mdunder--rootis reported, and a relative--fileis named by its absolute path, as the CLI names it;--rootand--filehelp).tests/integration/test_ingest_clients_live.py: run against a server, its ClickHouse and the reference extractor, with the worker pass in the test process.ingest_filepublishes a Markdown file.wait_for_ingestreturns itreadyat revision 1, andknowledge.getserves that revision with its tags.--no-waitprints the job.ingested_from).loom demouploads its file, waits for the job and finds the passage it asked about.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked: the SDK, the CLI and
loom demoend to end against a real server, ClickHouse and extractor; the failure paths in the unit tests above; and a review at every push.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code