Read the context pack for writing one unit
Code Mode: praxis.studio.works.units.retrieveContext
HTTP: GET /studio/v1/works/{work}/units/{unit}/context
Read everything a writer needs before touching one unit: the genre rules, the goal, the brief, the style, the upstream source, the reference entries this unit draws on, the synopses of the units before it, and the intent of this unit, assembled in a fixed order and measured against a token budget. Entries left out say why, so a missing detail is visible rather than silent. Same input gives the same pack, which is what makes a written result reproducible.
Signature
praxis.studio.works.units.retrieveContext(args:{path:{/** e.g. "wu-gang" */ work:string;/** e.g. "12" */ unit:string};query?:{/** e.g. 8000 */ budget_tokens?:number}}):Promise<{/** Work the pack was assembled for. e.g. "wk_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ work:string;/** Draft the unit belongs to. e.g. "drf_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ draft:string;/** Unit the pack was assembled for. e.g. "unt_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ unit:string;/** In-work number of that unit, which is what the unit path segment takes when the body is written. e.g. 12 */ number:number;/** Unit revision to pass as expected_revision when writing the body this pack was assembled for. e.g. 6 */ revision:number;/** The whole pack as one Markdown document in the fixed section order, ready to hand to a writer as is. e.g. "## 文体规则\\n长篇小说按章推进……" */ markdown:string;/** The sections the pack is made of, in output order, each with what it cost against the budget. */ sections:Array<{/** Which part of the pack this is; the sections are assembled in a fixed order so the stable parts come first. */ section:"genre"|"goal"|"brief"|"style"|"source"|"reference"|"timeline"|"previous"|"unit";/** Estimated tokens this section used, by the fixed estimator rather than a model tokenizer, so the same input always measures the same. e.g. 812 */ tokens:number;/** Whether this section was cut to fit the budget; only the reference, timeline and previous sections are ever truncated, and the genre, brief and unit sections al */ truncated:boolean}>;/** Token budget the pack was assembled under, either the value asked for or the service default. e.g. 8000 */ budget_tokens?:number;/** Tokens the assembled pack actually uses; it stays at or below the budget, since sections are cut to fit. e.g. 7340 */ used_tokens?:number;/** Reference entries that made it into the pack, in the order they appear, each with the reason it is there. */ included:Array<{/** Entry that was included. e.g. "ent_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ entry:string;/** Name of the entry as the library holds it, which is also what the text would mention. e.g. "乌江日报" */ name:string;/** Why this entry is in the pack; an entry appears once, under its strongest reason. */ reason:"pov"|"role"|"mentioned"|"attached"|"always"|"adaptation_source";/** Estimated tokens this entry costs in the pack, by the fixed estimator. e.g. 96 */ tokens:number}>;/** Reference entries left out, each with the reason, so a writer can tell a deliberate omission from a missing detail. */ excluded:Array<{/** Entry that was left out. e.g. "ent_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ entry:string;/** Name of that entry as the library holds it. e.g. "乌江日报" */ name:string;/** Why it was left out, which separates a deliberate exclusion from a detail that is simply missing. */ reason:"excluded_by_unit"|"tracking_never"|"over_budget"|"future_progression"}>;intent_diff?:{/** Intent revision the current body was written against. e.g. 4 */ from_revision?:number;/** Synopsis at that revision, shown beside the newer one so a writer can see what moved. e.g. "主角在报馆第一次见到通缉令。" */ synopsis?:string;/** Intent points at that revision, in the order they were written. */ points?:Array<string>};/** Hash of the revisions and the budget that produced this pack; the same hash means the same pack, which is what makes a written result reproducible. e.g. "3f9c1a7e" */ input_hash?:string}>;Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| work | path | string | yes | The work being addressed, either its organization-unique slug or its wk_ identifier; a slug case is what a person would say, and a renamed slug still resolves through its old value. |
| unit | path | string | yes | Unit being addressed, written as its in-work number such as 12, as #12, or as its unt_ identifier; the number never changes when the unit is moved. |
| budget_tokens | query | number | no | Token budget the pack must fit into; the reference, timeline and previous sections are cut to fit it while the genre, brief and unit sections always arrive whole. Omit it to use the service default. |
Responses
| Status | Content types | Description |
|---|---|---|
| 200 | application/json | The assembled pack with its sections, the entries included and left out, and the revision to write with. |
| 400 | application/json | INVALID_PARAMS means a field is missing, malformed or not allowed for this resource; correct the named field and repeat the call. |
| 401 | application/json | The API key is missing, invalid or carries no organization; send a valid organization key in the Authorization header. |
| 404 | application/json | WORK_NOT_FOUND, DRAFT_NOT_FOUND or UNIT_NOT_FOUND means one address in the path names nothing reachable; use the numbers and keys from the outline rather than a remembered one, since a unit that was deleted never returns. |
| 500 | application/json | INTERNAL means the request could not complete; re-read the resource before retrying a write, because the write may already have landed. |