[{"data":1,"prerenderedAt":1941},["ShallowReactive",2],{"docs:/docs/agents/tags":3},{"id":4,"title":5,"body":6,"description":1934,"extension":1935,"meta":1936,"navigation":95,"path":1937,"seo":1938,"stem":1939,"__hash__":1940},"docs/docs/agents/tags.md","Tag Vocabulary for Agents",{"type":7,"value":8,"toc":1921},"minimark",[9,14,23,28,39,459,466,471,570,573,577,590,786,790,842,845,849,856,914,926,930,961,1362,1366,1456,1460,1478,1909,1917],[10,11,13],"h1",{"id":12},"tag-vocabulary","Tag Vocabulary",[15,16,17,18,22],"p",{},"Capabilities, priority, and tags describe tasks and agents in ",[19,20,21],"code",{},"@nolag/agents",". This page is the reference for each, and for which of them the SDK uses for routing (only capabilities) versus carries for your code to read (priority and tags).",[24,25,27],"h2",{"id":26},"capabilities","Capabilities",[15,29,30,31,34,35,38],{},"A capability is a single string naming something a worker can do. Workers advertise a list of them through presence; a task names exactly one. ",[19,32,33],{},"dispatch()"," refuses to publish unless a connected agent advertises that capability, and ",[19,36,37],{},"onTask()"," hands a worker only the tasks whose capability is in its list.",[40,41,42],"code-tabs",{},[43,44,50],"pre",{"className":45,"code":46,"filename":47,"language":48,"meta":49,"style":49},"language-typescript shiki shiki-themes github-light github-dark","import { NoLag } from \"@nolag/js-sdk\";\nimport { NoLagAgents, Handoff } from \"@nolag/agents\";\n\n// Worker advertises capabilities through presence\nconst client = NoLag(WORKER_TOKEN);\nconst agents = new NoLagAgents({\n  client,\n  appName: APP_SLUG,\n  agentId: \"analyst-1\",\n  presence: { name: \"analyst-1\", role: \"agent\", capabilities: [\"research\", \"finance\", \"summarization\"] },\n});\nawait client.connect();\nawait agents.ready();\n\nconst room = agents.room(\"default-workflow\");\nconst handoff = new Handoff(room);\n\n// ...and handles the ones it wants\nhandoff.onTask([\"research\", \"finance\"], (task, respond) => {\n  respond(\"success\", { handled: task.capability });\n});\n\n// Orchestrator dispatches for one capability\nawait handoff.dispatch(\"finance\", { ticker: \"ACME\" });\n\n// Who can do what right now, from presence\nconsole.log(room.findAgents(\"finance\").map((a) => a.name));\nconsole.log(room.getAvailableCapabilities());\n","TypeScript","typescript","",[19,51,52,75,90,97,104,130,149,155,167,178,212,218,233,246,251,273,291,296,302,341,355,360,365,371,395,400,406,444],{"__ignoreMap":49},[53,54,57,61,65,68,72],"span",{"class":55,"line":56},"line",1,[53,58,60],{"class":59},"szBVR","import",[53,62,64],{"class":63},"sVt8B"," { NoLag } ",[53,66,67],{"class":59},"from",[53,69,71],{"class":70},"sZZnC"," \"@nolag/js-sdk\"",[53,73,74],{"class":63},";\n",[53,76,78,80,83,85,88],{"class":55,"line":77},2,[53,79,60],{"class":59},[53,81,82],{"class":63}," { NoLagAgents, Handoff } ",[53,84,67],{"class":59},[53,86,87],{"class":70}," \"@nolag/agents\"",[53,89,74],{"class":63},[53,91,93],{"class":55,"line":92},3,[53,94,96],{"emptyLinePlaceholder":95},true,"\n",[53,98,100],{"class":55,"line":99},4,[53,101,103],{"class":102},"sJ8bj","// Worker advertises capabilities through presence\n",[53,105,107,110,114,117,121,124,127],{"class":55,"line":106},5,[53,108,109],{"class":59},"const",[53,111,113],{"class":112},"sj4cs"," client",[53,115,116],{"class":59}," =",[53,118,120],{"class":119},"sScJk"," NoLag",[53,122,123],{"class":63},"(",[53,125,126],{"class":112},"WORKER_TOKEN",[53,128,129],{"class":63},");\n",[53,131,133,135,138,140,143,146],{"class":55,"line":132},6,[53,134,109],{"class":59},[53,136,137],{"class":112}," agents",[53,139,116],{"class":59},[53,141,142],{"class":59}," new",[53,144,145],{"class":119}," NoLagAgents",[53,147,148],{"class":63},"({\n",[53,150,152],{"class":55,"line":151},7,[53,153,154],{"class":63},"  client,\n",[53,156,158,161,164],{"class":55,"line":157},8,[53,159,160],{"class":63},"  appName: ",[53,162,163],{"class":112},"APP_SLUG",[53,165,166],{"class":63},",\n",[53,168,170,173,176],{"class":55,"line":169},9,[53,171,172],{"class":63},"  agentId: ",[53,174,175],{"class":70},"\"analyst-1\"",[53,177,166],{"class":63},[53,179,181,184,186,189,192,195,198,201,204,206,209],{"class":55,"line":180},10,[53,182,183],{"class":63},"  presence: { name: ",[53,185,175],{"class":70},[53,187,188],{"class":63},", role: ",[53,190,191],{"class":70},"\"agent\"",[53,193,194],{"class":63},", capabilities: [",[53,196,197],{"class":70},"\"research\"",[53,199,200],{"class":63},", ",[53,202,203],{"class":70},"\"finance\"",[53,205,200],{"class":63},[53,207,208],{"class":70},"\"summarization\"",[53,210,211],{"class":63},"] },\n",[53,213,215],{"class":55,"line":214},11,[53,216,217],{"class":63},"});\n",[53,219,221,224,227,230],{"class":55,"line":220},12,[53,222,223],{"class":59},"await",[53,225,226],{"class":63}," client.",[53,228,229],{"class":119},"connect",[53,231,232],{"class":63},"();\n",[53,234,236,238,241,244],{"class":55,"line":235},13,[53,237,223],{"class":59},[53,239,240],{"class":63}," agents.",[53,242,243],{"class":119},"ready",[53,245,232],{"class":63},[53,247,249],{"class":55,"line":248},14,[53,250,96],{"emptyLinePlaceholder":95},[53,252,254,256,259,261,263,266,268,271],{"class":55,"line":253},15,[53,255,109],{"class":59},[53,257,258],{"class":112}," room",[53,260,116],{"class":59},[53,262,240],{"class":63},[53,264,265],{"class":119},"room",[53,267,123],{"class":63},[53,269,270],{"class":70},"\"default-workflow\"",[53,272,129],{"class":63},[53,274,276,278,281,283,285,288],{"class":55,"line":275},16,[53,277,109],{"class":59},[53,279,280],{"class":112}," handoff",[53,282,116],{"class":59},[53,284,142],{"class":59},[53,286,287],{"class":119}," Handoff",[53,289,290],{"class":63},"(room);\n",[53,292,294],{"class":55,"line":293},17,[53,295,96],{"emptyLinePlaceholder":95},[53,297,299],{"class":55,"line":298},18,[53,300,301],{"class":102},"// ...and handles the ones it wants\n",[53,303,305,308,311,314,316,318,320,323,327,329,332,335,338],{"class":55,"line":304},19,[53,306,307],{"class":63},"handoff.",[53,309,310],{"class":119},"onTask",[53,312,313],{"class":63},"([",[53,315,197],{"class":70},[53,317,200],{"class":63},[53,319,203],{"class":70},[53,321,322],{"class":63},"], (",[53,324,326],{"class":325},"s4XuR","task",[53,328,200],{"class":63},[53,330,331],{"class":325},"respond",[53,333,334],{"class":63},") ",[53,336,337],{"class":59},"=>",[53,339,340],{"class":63}," {\n",[53,342,344,347,349,352],{"class":55,"line":343},20,[53,345,346],{"class":119},"  respond",[53,348,123],{"class":63},[53,350,351],{"class":70},"\"success\"",[53,353,354],{"class":63},", { handled: task.capability });\n",[53,356,358],{"class":55,"line":357},21,[53,359,217],{"class":63},[53,361,363],{"class":55,"line":362},22,[53,364,96],{"emptyLinePlaceholder":95},[53,366,368],{"class":55,"line":367},23,[53,369,370],{"class":102},"// Orchestrator dispatches for one capability\n",[53,372,374,376,379,382,384,386,389,392],{"class":55,"line":373},24,[53,375,223],{"class":59},[53,377,378],{"class":63}," handoff.",[53,380,381],{"class":119},"dispatch",[53,383,123],{"class":63},[53,385,203],{"class":70},[53,387,388],{"class":63},", { ticker: ",[53,390,391],{"class":70},"\"ACME\"",[53,393,394],{"class":63}," });\n",[53,396,398],{"class":55,"line":397},25,[53,399,96],{"emptyLinePlaceholder":95},[53,401,403],{"class":55,"line":402},26,[53,404,405],{"class":102},"// Who can do what right now, from presence\n",[53,407,409,412,415,418,421,423,425,428,431,434,437,439,441],{"class":55,"line":408},27,[53,410,411],{"class":63},"console.",[53,413,414],{"class":119},"log",[53,416,417],{"class":63},"(room.",[53,419,420],{"class":119},"findAgents",[53,422,123],{"class":63},[53,424,203],{"class":70},[53,426,427],{"class":63},").",[53,429,430],{"class":119},"map",[53,432,433],{"class":63},"((",[53,435,436],{"class":325},"a",[53,438,334],{"class":63},[53,440,337],{"class":59},[53,442,443],{"class":63}," a.name));\n",[53,445,447,449,451,453,456],{"class":55,"line":446},28,[53,448,411],{"class":63},[53,450,414],{"class":119},[53,452,417],{"class":63},[53,454,455],{"class":119},"getAvailableCapabilities",[53,457,458],{"class":63},"());\n",[15,460,461,462,465],{},"A task has one capability, so there is no \"worker must have both\" matching. If a job needs two skills, either name a combined capability (",[19,463,464],{},"analyze-earnings",") or dispatch two tasks.",[467,468,470],"h3",{"id":469},"common-capability-names","Common capability names",[472,473,474,487],"table",{},[475,476,477],"thead",{},[478,479,480,484],"tr",{},[481,482,483],"th",{},"Capability",[481,485,486],{},"Description",[488,489,490,501,511,521,531,541,550,560],"tbody",{},[478,491,492,498],{},[493,494,495],"td",{},[19,496,497],{},"research",[493,499,500],{},"Web research, data gathering, source verification",[478,502,503,508],{},[493,504,505],{},[19,506,507],{},"drafting",[493,509,510],{},"Content creation, report writing, email composition",[478,512,513,518],{},[493,514,515],{},[19,516,517],{},"review",[493,519,520],{},"Quality review, fact-checking, compliance checks",[478,522,523,528],{},[493,524,525],{},[19,526,527],{},"summarization",[493,529,530],{},"Text summarization, key point extraction",[478,532,533,538],{},[493,534,535],{},[19,536,537],{},"finance",[493,539,540],{},"Financial analysis, calculations, reporting",[478,542,543,547],{},[493,544,545],{},[19,546,19],{},[493,548,549],{},"Code generation, review, debugging",[478,551,552,557],{},[493,553,554],{},[19,555,556],{},"translation",[493,558,559],{},"Language translation, localization",[478,561,562,567],{},[493,563,564],{},[19,565,566],{},"customer-support",[493,568,569],{},"User queries, issue resolution, FAQ",[15,571,572],{},"These are conventions, not enforced values. Use any string that makes sense for your domain.",[24,574,576],{"id":575},"priority","Priority",[15,578,579,581,582,585,586,589],{},[19,580,575],{}," is a field on the task envelope. It has four values, defaults to ",[19,583,584],{},"medium",", and is delivered to the worker as-is. The SDK does not queue, reorder, or preempt tasks by priority; a worker that cares reads ",[19,587,588],{},"task.priority"," and decides what to do.",[40,591,592],{},[43,593,595],{"className":45,"code":594,"filename":47,"language":48,"meta":49,"style":49},"import { Handoff } from \"@nolag/agents\";\n\nconst handoff = new Handoff(room);\n\n// Dispatch with a priority\nawait handoff.dispatch(\"drafting\", { report: \"q3\" }, { priority: \"critical\" });\n\n// A worker reads it and chooses its own policy\nhandoff.onTask([\"drafting\"], async (task, respond) => {\n  if (task.priority === \"low\" && busy()) {\n    respond(\"error\", {}, { code: \"busy\", message: \"deferring low-priority work\" });\n    return;\n  }\n  respond(\"success\", { draft: await draft(task.payload) });\n});\n",[19,596,597,610,614,628,632,637,664,668,673,704,727,751,758,763,782],{"__ignoreMap":49},[53,598,599,601,604,606,608],{"class":55,"line":56},[53,600,60],{"class":59},[53,602,603],{"class":63}," { Handoff } ",[53,605,67],{"class":59},[53,607,87],{"class":70},[53,609,74],{"class":63},[53,611,612],{"class":55,"line":77},[53,613,96],{"emptyLinePlaceholder":95},[53,615,616,618,620,622,624,626],{"class":55,"line":92},[53,617,109],{"class":59},[53,619,280],{"class":112},[53,621,116],{"class":59},[53,623,142],{"class":59},[53,625,287],{"class":119},[53,627,290],{"class":63},[53,629,630],{"class":55,"line":99},[53,631,96],{"emptyLinePlaceholder":95},[53,633,634],{"class":55,"line":106},[53,635,636],{"class":102},"// Dispatch with a priority\n",[53,638,639,641,643,645,647,650,653,656,659,662],{"class":55,"line":132},[53,640,223],{"class":59},[53,642,378],{"class":63},[53,644,381],{"class":119},[53,646,123],{"class":63},[53,648,649],{"class":70},"\"drafting\"",[53,651,652],{"class":63},", { report: ",[53,654,655],{"class":70},"\"q3\"",[53,657,658],{"class":63}," }, { priority: ",[53,660,661],{"class":70},"\"critical\"",[53,663,394],{"class":63},[53,665,666],{"class":55,"line":151},[53,667,96],{"emptyLinePlaceholder":95},[53,669,670],{"class":55,"line":157},[53,671,672],{"class":102},"// A worker reads it and chooses its own policy\n",[53,674,675,677,679,681,683,686,689,692,694,696,698,700,702],{"class":55,"line":169},[53,676,307],{"class":63},[53,678,310],{"class":119},[53,680,313],{"class":63},[53,682,649],{"class":70},[53,684,685],{"class":63},"], ",[53,687,688],{"class":59},"async",[53,690,691],{"class":63}," (",[53,693,326],{"class":325},[53,695,200],{"class":63},[53,697,331],{"class":325},[53,699,334],{"class":63},[53,701,337],{"class":59},[53,703,340],{"class":63},[53,705,706,709,712,715,718,721,724],{"class":55,"line":180},[53,707,708],{"class":59},"  if",[53,710,711],{"class":63}," (task.priority ",[53,713,714],{"class":59},"===",[53,716,717],{"class":70}," \"low\"",[53,719,720],{"class":59}," &&",[53,722,723],{"class":119}," busy",[53,725,726],{"class":63},"()) {\n",[53,728,729,732,734,737,740,743,746,749],{"class":55,"line":214},[53,730,731],{"class":119},"    respond",[53,733,123],{"class":63},[53,735,736],{"class":70},"\"error\"",[53,738,739],{"class":63},", {}, { code: ",[53,741,742],{"class":70},"\"busy\"",[53,744,745],{"class":63},", message: ",[53,747,748],{"class":70},"\"deferring low-priority work\"",[53,750,394],{"class":63},[53,752,753,756],{"class":55,"line":220},[53,754,755],{"class":59},"    return",[53,757,74],{"class":63},[53,759,760],{"class":55,"line":235},[53,761,762],{"class":63},"  }\n",[53,764,765,767,769,771,774,776,779],{"class":55,"line":248},[53,766,346],{"class":119},[53,768,123],{"class":63},[53,770,351],{"class":70},[53,772,773],{"class":63},", { draft: ",[53,775,223],{"class":59},[53,777,778],{"class":119}," draft",[53,780,781],{"class":63},"(task.payload) });\n",[53,783,784],{"class":55,"line":253},[53,785,217],{"class":63},[467,787,789],{"id":788},"priority-values","Priority values",[472,791,792,801],{},[475,793,794],{},[478,795,796,798],{},[481,797,576],{},[481,799,800],{},"Suggested meaning",[488,802,803,813,823,832],{},[478,804,805,810],{},[493,806,807],{},[19,808,809],{},"critical",[493,811,812],{},"Drop other work for this",[478,814,815,820],{},[493,816,817],{},[19,818,819],{},"high",[493,821,822],{},"Ahead of routine work",[478,824,825,829],{},[493,826,827],{},[19,828,584],{},[493,830,831],{},"Default",[478,833,834,839],{},[493,835,836],{},[19,837,838],{},"low",[493,840,841],{},"Background work",[15,843,844],{},"The meanings are suggestions for your worker code; the transport treats all four identically.",[24,846,848],{"id":847},"task-outcomes","Task outcomes",[15,850,851,852,855],{},"There are no automatic status tags or lifecycle events. A task has two observable moments: the dispatcher publishes it, and the worker calls ",[19,853,854],{},"respond()",". The result envelope carries the outcome:",[472,857,858,870],{},[475,859,860],{},[478,861,862,867],{},[481,863,864],{},[19,865,866],{},"result.status",[481,868,869],{},"Meaning",[488,871,872,886,904],{},[478,873,874,879],{},[493,875,876],{},[19,877,878],{},"success",[493,880,881,882,885],{},"Worker finished; ",[19,883,884],{},"payload"," holds the output",[478,887,888,893],{},[493,889,890],{},[19,891,892],{},"error",[493,894,895,896,899,900,903],{},"Worker reported a failure; ",[19,897,898],{},"error.code"," and ",[19,901,902],{},"error.message"," say why",[478,905,906,911],{},[493,907,908],{},[19,909,910],{},"partial",[493,912,913],{},"Worker returned an incomplete result",[15,915,916,917,920,921,925],{},"A task nobody answers has no status at all: with ",[19,918,919],{},"waitForResult: true"," the dispatch promise rejects when the timeout passes. Anything in between (started, claimed, retrying) exists only if your worker emits it with ",[436,922,924],{"href":923},"/docs/agents/patterns#observe","Observe",".",[24,927,929],{"id":928},"custom-tags","Custom tags",[15,931,932,933,936,937,940,941,944,945,899,948,951,952,955,956,958,959,925],{},"Tasks carry an optional ",[19,934,935],{},"tags: string[]",". The convention is ",[19,938,939],{},"prefix:value",", and the ",[19,942,943],{},"tag()"," helper builds one; ",[19,946,947],{},"TAG_PREFIX",[19,949,950],{},"TAG_FLAGS"," hold the standard prefixes and flags. Agents carry free-form ",[19,953,954],{},"metadata"," on their presence instead. Both are delivered as data for your code to read; neither is consulted by ",[19,957,33],{}," or ",[19,960,37],{},[40,962,963],{},[43,964,966],{"className":45,"code":965,"filename":47,"language":48,"meta":49,"style":49},"import { NoLag } from \"@nolag/js-sdk\";\nimport { NoLagAgents, Handoff, tag, TAG_PREFIX, TAG_FLAGS } from \"@nolag/agents\";\n\n// Tags on a task\nconst handoff = new Handoff(room);\nawait handoff.dispatch(\n  \"review\",\n  { documentId: \"doc-42\" },\n  {\n    tags: [\n      tag(TAG_PREFIX.TENANT, \"acme-corp\"), // \"tenant:acme-corp\"\n      tag(\"department\", \"legal\"),          // \"department:legal\"\n      tag(\"region\", \"eu-west\"),\n      TAG_FLAGS.REQUIRES_AUDIT,            // \"requires_audit\"\n    ],\n  },\n);\n\n// A worker reads them\nhandoff.onTask([\"review\"], (task, respond) => {\n  const audited = task.tags?.includes(TAG_FLAGS.REQUIRES_AUDIT) ?? false;\n  respond(\"success\", { audited });\n});\n\n// Metadata on an agent, advertised through presence\nconst client = NoLag(REVIEWER_TOKEN);\nconst reviewer = new NoLagAgents({\n  client,\n  appName: APP_SLUG,\n  agentId: \"reviewer-eu-1\",\n  presence: {\n    name: \"reviewer-eu-1\",\n    role: \"agent\",\n    capabilities: [\"review\"],\n    metadata: { department: \"legal\", region: \"eu-west\", clearance: \"confidential\" },\n  },\n});\n",[19,967,968,980,993,997,1002,1016,1027,1034,1045,1050,1055,1080,1100,1117,1133,1138,1143,1147,1151,1156,1181,1215,1226,1230,1234,1239,1256,1271,1275,1284,1294,1300,1310,1320,1331,1352,1357],{"__ignoreMap":49},[53,969,970,972,974,976,978],{"class":55,"line":56},[53,971,60],{"class":59},[53,973,64],{"class":63},[53,975,67],{"class":59},[53,977,71],{"class":70},[53,979,74],{"class":63},[53,981,982,984,987,989,991],{"class":55,"line":77},[53,983,60],{"class":59},[53,985,986],{"class":63}," { NoLagAgents, Handoff, tag, TAG_PREFIX, TAG_FLAGS } ",[53,988,67],{"class":59},[53,990,87],{"class":70},[53,992,74],{"class":63},[53,994,995],{"class":55,"line":92},[53,996,96],{"emptyLinePlaceholder":95},[53,998,999],{"class":55,"line":99},[53,1000,1001],{"class":102},"// Tags on a task\n",[53,1003,1004,1006,1008,1010,1012,1014],{"class":55,"line":106},[53,1005,109],{"class":59},[53,1007,280],{"class":112},[53,1009,116],{"class":59},[53,1011,142],{"class":59},[53,1013,287],{"class":119},[53,1015,290],{"class":63},[53,1017,1018,1020,1022,1024],{"class":55,"line":132},[53,1019,223],{"class":59},[53,1021,378],{"class":63},[53,1023,381],{"class":119},[53,1025,1026],{"class":63},"(\n",[53,1028,1029,1032],{"class":55,"line":151},[53,1030,1031],{"class":70},"  \"review\"",[53,1033,166],{"class":63},[53,1035,1036,1039,1042],{"class":55,"line":157},[53,1037,1038],{"class":63},"  { documentId: ",[53,1040,1041],{"class":70},"\"doc-42\"",[53,1043,1044],{"class":63}," },\n",[53,1046,1047],{"class":55,"line":169},[53,1048,1049],{"class":63},"  {\n",[53,1051,1052],{"class":55,"line":180},[53,1053,1054],{"class":63},"    tags: [\n",[53,1056,1057,1060,1062,1064,1066,1069,1071,1074,1077],{"class":55,"line":214},[53,1058,1059],{"class":119},"      tag",[53,1061,123],{"class":63},[53,1063,947],{"class":112},[53,1065,925],{"class":63},[53,1067,1068],{"class":112},"TENANT",[53,1070,200],{"class":63},[53,1072,1073],{"class":70},"\"acme-corp\"",[53,1075,1076],{"class":63},"), ",[53,1078,1079],{"class":102},"// \"tenant:acme-corp\"\n",[53,1081,1082,1084,1086,1089,1091,1094,1097],{"class":55,"line":220},[53,1083,1059],{"class":119},[53,1085,123],{"class":63},[53,1087,1088],{"class":70},"\"department\"",[53,1090,200],{"class":63},[53,1092,1093],{"class":70},"\"legal\"",[53,1095,1096],{"class":63},"),          ",[53,1098,1099],{"class":102},"// \"department:legal\"\n",[53,1101,1102,1104,1106,1109,1111,1114],{"class":55,"line":235},[53,1103,1059],{"class":119},[53,1105,123],{"class":63},[53,1107,1108],{"class":70},"\"region\"",[53,1110,200],{"class":63},[53,1112,1113],{"class":70},"\"eu-west\"",[53,1115,1116],{"class":63},"),\n",[53,1118,1119,1122,1124,1127,1130],{"class":55,"line":248},[53,1120,1121],{"class":112},"      TAG_FLAGS",[53,1123,925],{"class":63},[53,1125,1126],{"class":112},"REQUIRES_AUDIT",[53,1128,1129],{"class":63},",            ",[53,1131,1132],{"class":102},"// \"requires_audit\"\n",[53,1134,1135],{"class":55,"line":253},[53,1136,1137],{"class":63},"    ],\n",[53,1139,1140],{"class":55,"line":275},[53,1141,1142],{"class":63},"  },\n",[53,1144,1145],{"class":55,"line":293},[53,1146,129],{"class":63},[53,1148,1149],{"class":55,"line":298},[53,1150,96],{"emptyLinePlaceholder":95},[53,1152,1153],{"class":55,"line":304},[53,1154,1155],{"class":102},"// A worker reads them\n",[53,1157,1158,1160,1162,1164,1167,1169,1171,1173,1175,1177,1179],{"class":55,"line":343},[53,1159,307],{"class":63},[53,1161,310],{"class":119},[53,1163,313],{"class":63},[53,1165,1166],{"class":70},"\"review\"",[53,1168,322],{"class":63},[53,1170,326],{"class":325},[53,1172,200],{"class":63},[53,1174,331],{"class":325},[53,1176,334],{"class":63},[53,1178,337],{"class":59},[53,1180,340],{"class":63},[53,1182,1183,1186,1189,1191,1194,1197,1199,1201,1203,1205,1207,1210,1213],{"class":55,"line":357},[53,1184,1185],{"class":59},"  const",[53,1187,1188],{"class":112}," audited",[53,1190,116],{"class":59},[53,1192,1193],{"class":63}," task.tags?.",[53,1195,1196],{"class":119},"includes",[53,1198,123],{"class":63},[53,1200,950],{"class":112},[53,1202,925],{"class":63},[53,1204,1126],{"class":112},[53,1206,334],{"class":63},[53,1208,1209],{"class":59},"??",[53,1211,1212],{"class":112}," false",[53,1214,74],{"class":63},[53,1216,1217,1219,1221,1223],{"class":55,"line":362},[53,1218,346],{"class":119},[53,1220,123],{"class":63},[53,1222,351],{"class":70},[53,1224,1225],{"class":63},", { audited });\n",[53,1227,1228],{"class":55,"line":367},[53,1229,217],{"class":63},[53,1231,1232],{"class":55,"line":373},[53,1233,96],{"emptyLinePlaceholder":95},[53,1235,1236],{"class":55,"line":397},[53,1237,1238],{"class":102},"// Metadata on an agent, advertised through presence\n",[53,1240,1241,1243,1245,1247,1249,1251,1254],{"class":55,"line":402},[53,1242,109],{"class":59},[53,1244,113],{"class":112},[53,1246,116],{"class":59},[53,1248,120],{"class":119},[53,1250,123],{"class":63},[53,1252,1253],{"class":112},"REVIEWER_TOKEN",[53,1255,129],{"class":63},[53,1257,1258,1260,1263,1265,1267,1269],{"class":55,"line":408},[53,1259,109],{"class":59},[53,1261,1262],{"class":112}," reviewer",[53,1264,116],{"class":59},[53,1266,142],{"class":59},[53,1268,145],{"class":119},[53,1270,148],{"class":63},[53,1272,1273],{"class":55,"line":446},[53,1274,154],{"class":63},[53,1276,1278,1280,1282],{"class":55,"line":1277},29,[53,1279,160],{"class":63},[53,1281,163],{"class":112},[53,1283,166],{"class":63},[53,1285,1287,1289,1292],{"class":55,"line":1286},30,[53,1288,172],{"class":63},[53,1290,1291],{"class":70},"\"reviewer-eu-1\"",[53,1293,166],{"class":63},[53,1295,1297],{"class":55,"line":1296},31,[53,1298,1299],{"class":63},"  presence: {\n",[53,1301,1303,1306,1308],{"class":55,"line":1302},32,[53,1304,1305],{"class":63},"    name: ",[53,1307,1291],{"class":70},[53,1309,166],{"class":63},[53,1311,1313,1316,1318],{"class":55,"line":1312},33,[53,1314,1315],{"class":63},"    role: ",[53,1317,191],{"class":70},[53,1319,166],{"class":63},[53,1321,1323,1326,1328],{"class":55,"line":1322},34,[53,1324,1325],{"class":63},"    capabilities: [",[53,1327,1166],{"class":70},[53,1329,1330],{"class":63},"],\n",[53,1332,1334,1337,1339,1342,1344,1347,1350],{"class":55,"line":1333},35,[53,1335,1336],{"class":63},"    metadata: { department: ",[53,1338,1093],{"class":70},[53,1340,1341],{"class":63},", region: ",[53,1343,1113],{"class":70},[53,1345,1346],{"class":63},", clearance: ",[53,1348,1349],{"class":70},"\"confidential\"",[53,1351,1044],{"class":63},[53,1353,1355],{"class":55,"line":1354},36,[53,1356,1142],{"class":63},[53,1358,1360],{"class":55,"line":1359},37,[53,1361,217],{"class":63},[467,1363,1365],{"id":1364},"custom-tag-patterns","Custom tag patterns",[472,1367,1368,1381],{},[475,1369,1370],{},[478,1371,1372,1375,1378],{},[481,1373,1374],{},"Pattern",[481,1376,1377],{},"Example",[481,1379,1380],{},"Use case",[488,1382,1383,1396,1409,1427,1440],{},[478,1384,1385,1388,1393],{},[493,1386,1387],{},"Department",[493,1389,1390],{},[19,1391,1392],{},"department:legal",[493,1394,1395],{},"Let workers accept or decline by department",[478,1397,1398,1401,1406],{},[493,1399,1400],{},"Region affinity",[493,1402,1403],{},[19,1404,1405],{},"region:eu-west",[493,1407,1408],{},"Keep data processing within a geographic region",[478,1410,1411,1414,1419],{},[493,1412,1413],{},"Tenant",[493,1415,1416],{},[19,1417,1418],{},"tenant:acme-corp",[493,1420,1421,1422,1426],{},"Label work in multi-tenant agent systems (for hard isolation use ",[436,1423,1425],{"href":1424},"/docs/scopes/getting-started","Access Scopes",")",[478,1428,1429,1432,1437],{},[493,1430,1431],{},"Model selection",[493,1433,1434],{},[19,1435,1436],{},"model:gpt-4o",[493,1438,1439],{},"Ask for a specific LLM",[478,1441,1442,1445,1453],{},[493,1443,1444],{},"Flags",[493,1446,1447,200,1450],{},[19,1448,1449],{},"requires_human",[19,1451,1452],{},"requires_audit",[493,1454,1455],{},"Mark work that needs a human step or an audit entry",[24,1457,1459],{"id":1458},"server-side-routing","Server-side routing",[15,1461,1462,1463,1465,1466,1469,1470,1473,1474,1477],{},"By default every worker in a room receives every task and ",[19,1464,310],{}," discards the ones it cannot handle. For a busy room you can move that selection to the broker with subscription filters: a worker joins the room with the filter values it wants, and the dispatcher publishes each task tagged with one. ",[19,1467,1468],{},"Handoff.dispatch()"," publishes without a filter, so the dispatcher uses ",[19,1471,1472],{},"room.publishTask()"," directly and reads results from the room's ",[19,1475,1476],{},"result"," event.",[40,1479,1480,1695],{},[43,1481,1484],{"className":45,"code":1482,"filename":1483,"language":48,"meta":49,"style":49},"import { NoLag } from \"@nolag/js-sdk\";\nimport { NoLagAgents, Handoff } from \"@nolag/agents\";\n\nconst client = NoLag(WORKER_TOKEN);\nconst agents = new NoLagAgents({\n  client,\n  appName: APP_SLUG,\n  agentId: \"researcher-1\",\n  presence: { name: \"researcher-1\", role: \"agent\", capabilities: [\"research\", \"finance\"] },\n});\nawait client.connect();\nawait agents.ready();\n\n// The broker now sends this worker only tasks published with one of these filter values\nconst room = agents.room(\"default-workflow\", { filters: [\"research\", \"finance\"] });\nnew Handoff(room).onTask([\"research\", \"finance\"], (task, respond) => {\n  respond(\"success\", { done: task.taskId });\n});\n","Worker",[19,1485,1486,1498,1510,1514,1530,1544,1548,1556,1565,1585,1589,1599,1609,1613,1618,1646,1680,1691],{"__ignoreMap":49},[53,1487,1488,1490,1492,1494,1496],{"class":55,"line":56},[53,1489,60],{"class":59},[53,1491,64],{"class":63},[53,1493,67],{"class":59},[53,1495,71],{"class":70},[53,1497,74],{"class":63},[53,1499,1500,1502,1504,1506,1508],{"class":55,"line":77},[53,1501,60],{"class":59},[53,1503,82],{"class":63},[53,1505,67],{"class":59},[53,1507,87],{"class":70},[53,1509,74],{"class":63},[53,1511,1512],{"class":55,"line":92},[53,1513,96],{"emptyLinePlaceholder":95},[53,1515,1516,1518,1520,1522,1524,1526,1528],{"class":55,"line":99},[53,1517,109],{"class":59},[53,1519,113],{"class":112},[53,1521,116],{"class":59},[53,1523,120],{"class":119},[53,1525,123],{"class":63},[53,1527,126],{"class":112},[53,1529,129],{"class":63},[53,1531,1532,1534,1536,1538,1540,1542],{"class":55,"line":106},[53,1533,109],{"class":59},[53,1535,137],{"class":112},[53,1537,116],{"class":59},[53,1539,142],{"class":59},[53,1541,145],{"class":119},[53,1543,148],{"class":63},[53,1545,1546],{"class":55,"line":132},[53,1547,154],{"class":63},[53,1549,1550,1552,1554],{"class":55,"line":151},[53,1551,160],{"class":63},[53,1553,163],{"class":112},[53,1555,166],{"class":63},[53,1557,1558,1560,1563],{"class":55,"line":157},[53,1559,172],{"class":63},[53,1561,1562],{"class":70},"\"researcher-1\"",[53,1564,166],{"class":63},[53,1566,1567,1569,1571,1573,1575,1577,1579,1581,1583],{"class":55,"line":169},[53,1568,183],{"class":63},[53,1570,1562],{"class":70},[53,1572,188],{"class":63},[53,1574,191],{"class":70},[53,1576,194],{"class":63},[53,1578,197],{"class":70},[53,1580,200],{"class":63},[53,1582,203],{"class":70},[53,1584,211],{"class":63},[53,1586,1587],{"class":55,"line":180},[53,1588,217],{"class":63},[53,1590,1591,1593,1595,1597],{"class":55,"line":214},[53,1592,223],{"class":59},[53,1594,226],{"class":63},[53,1596,229],{"class":119},[53,1598,232],{"class":63},[53,1600,1601,1603,1605,1607],{"class":55,"line":220},[53,1602,223],{"class":59},[53,1604,240],{"class":63},[53,1606,243],{"class":119},[53,1608,232],{"class":63},[53,1610,1611],{"class":55,"line":235},[53,1612,96],{"emptyLinePlaceholder":95},[53,1614,1615],{"class":55,"line":248},[53,1616,1617],{"class":102},"// The broker now sends this worker only tasks published with one of these filter values\n",[53,1619,1620,1622,1624,1626,1628,1630,1632,1634,1637,1639,1641,1643],{"class":55,"line":253},[53,1621,109],{"class":59},[53,1623,258],{"class":112},[53,1625,116],{"class":59},[53,1627,240],{"class":63},[53,1629,265],{"class":119},[53,1631,123],{"class":63},[53,1633,270],{"class":70},[53,1635,1636],{"class":63},", { filters: [",[53,1638,197],{"class":70},[53,1640,200],{"class":63},[53,1642,203],{"class":70},[53,1644,1645],{"class":63},"] });\n",[53,1647,1648,1651,1653,1656,1658,1660,1662,1664,1666,1668,1670,1672,1674,1676,1678],{"class":55,"line":275},[53,1649,1650],{"class":59},"new",[53,1652,287],{"class":119},[53,1654,1655],{"class":63},"(room).",[53,1657,310],{"class":119},[53,1659,313],{"class":63},[53,1661,197],{"class":70},[53,1663,200],{"class":63},[53,1665,203],{"class":70},[53,1667,322],{"class":63},[53,1669,326],{"class":325},[53,1671,200],{"class":63},[53,1673,331],{"class":325},[53,1675,334],{"class":63},[53,1677,337],{"class":59},[53,1679,340],{"class":63},[53,1681,1682,1684,1686,1688],{"class":55,"line":293},[53,1683,346],{"class":119},[53,1685,123],{"class":63},[53,1687,351],{"class":70},[53,1689,1690],{"class":63},", { done: task.taskId });\n",[53,1692,1693],{"class":55,"line":298},[53,1694,217],{"class":63},[43,1696,1699],{"className":45,"code":1697,"filename":1698,"language":48,"meta":49,"style":49},"import { NoLag } from \"@nolag/js-sdk\";\nimport { NoLagAgents, createTaskEnvelope } from \"@nolag/agents\";\n\nconst client = NoLag(ORCHESTRATOR_TOKEN);\nconst agents = new NoLagAgents({ client, appName: APP_SLUG, agentId: \"orchestrator\" });\nawait client.connect();\nawait agents.ready();\n\nconst room = agents.room(\"default-workflow\");\n\n// Results come back to this agent's id; read them from the room\nroom.on(\"result\", (result) => {\n  console.log(result.taskId, result.status, result.payload);\n});\n\n// Publish with the capability as the filter value\nconst task = createTaskEnvelope(\"research\", { url: \"https://example.com\" }, { priority: \"high\" });\nroom.publishTask(task, { filter: task.capability });\n","Dispatcher",[19,1700,1701,1713,1726,1730,1747,1772,1782,1792,1796,1814,1818,1823,1847,1857,1861,1865,1870,1899],{"__ignoreMap":49},[53,1702,1703,1705,1707,1709,1711],{"class":55,"line":56},[53,1704,60],{"class":59},[53,1706,64],{"class":63},[53,1708,67],{"class":59},[53,1710,71],{"class":70},[53,1712,74],{"class":63},[53,1714,1715,1717,1720,1722,1724],{"class":55,"line":77},[53,1716,60],{"class":59},[53,1718,1719],{"class":63}," { NoLagAgents, createTaskEnvelope } ",[53,1721,67],{"class":59},[53,1723,87],{"class":70},[53,1725,74],{"class":63},[53,1727,1728],{"class":55,"line":92},[53,1729,96],{"emptyLinePlaceholder":95},[53,1731,1732,1734,1736,1738,1740,1742,1745],{"class":55,"line":99},[53,1733,109],{"class":59},[53,1735,113],{"class":112},[53,1737,116],{"class":59},[53,1739,120],{"class":119},[53,1741,123],{"class":63},[53,1743,1744],{"class":112},"ORCHESTRATOR_TOKEN",[53,1746,129],{"class":63},[53,1748,1749,1751,1753,1755,1757,1759,1762,1764,1767,1770],{"class":55,"line":106},[53,1750,109],{"class":59},[53,1752,137],{"class":112},[53,1754,116],{"class":59},[53,1756,142],{"class":59},[53,1758,145],{"class":119},[53,1760,1761],{"class":63},"({ client, appName: ",[53,1763,163],{"class":112},[53,1765,1766],{"class":63},", agentId: ",[53,1768,1769],{"class":70},"\"orchestrator\"",[53,1771,394],{"class":63},[53,1773,1774,1776,1778,1780],{"class":55,"line":132},[53,1775,223],{"class":59},[53,1777,226],{"class":63},[53,1779,229],{"class":119},[53,1781,232],{"class":63},[53,1783,1784,1786,1788,1790],{"class":55,"line":151},[53,1785,223],{"class":59},[53,1787,240],{"class":63},[53,1789,243],{"class":119},[53,1791,232],{"class":63},[53,1793,1794],{"class":55,"line":157},[53,1795,96],{"emptyLinePlaceholder":95},[53,1797,1798,1800,1802,1804,1806,1808,1810,1812],{"class":55,"line":169},[53,1799,109],{"class":59},[53,1801,258],{"class":112},[53,1803,116],{"class":59},[53,1805,240],{"class":63},[53,1807,265],{"class":119},[53,1809,123],{"class":63},[53,1811,270],{"class":70},[53,1813,129],{"class":63},[53,1815,1816],{"class":55,"line":180},[53,1817,96],{"emptyLinePlaceholder":95},[53,1819,1820],{"class":55,"line":214},[53,1821,1822],{"class":102},"// Results come back to this agent's id; read them from the room\n",[53,1824,1825,1828,1831,1833,1836,1839,1841,1843,1845],{"class":55,"line":220},[53,1826,1827],{"class":63},"room.",[53,1829,1830],{"class":119},"on",[53,1832,123],{"class":63},[53,1834,1835],{"class":70},"\"result\"",[53,1837,1838],{"class":63},", (",[53,1840,1476],{"class":325},[53,1842,334],{"class":63},[53,1844,337],{"class":59},[53,1846,340],{"class":63},[53,1848,1849,1852,1854],{"class":55,"line":235},[53,1850,1851],{"class":63},"  console.",[53,1853,414],{"class":119},[53,1855,1856],{"class":63},"(result.taskId, result.status, result.payload);\n",[53,1858,1859],{"class":55,"line":248},[53,1860,217],{"class":63},[53,1862,1863],{"class":55,"line":253},[53,1864,96],{"emptyLinePlaceholder":95},[53,1866,1867],{"class":55,"line":275},[53,1868,1869],{"class":102},"// Publish with the capability as the filter value\n",[53,1871,1872,1874,1877,1879,1882,1884,1886,1889,1892,1894,1897],{"class":55,"line":293},[53,1873,109],{"class":59},[53,1875,1876],{"class":112}," task",[53,1878,116],{"class":59},[53,1880,1881],{"class":119}," createTaskEnvelope",[53,1883,123],{"class":63},[53,1885,197],{"class":70},[53,1887,1888],{"class":63},", { url: ",[53,1890,1891],{"class":70},"\"https://example.com\"",[53,1893,658],{"class":63},[53,1895,1896],{"class":70},"\"high\"",[53,1898,394],{"class":63},[53,1900,1901,1903,1906],{"class":55,"line":298},[53,1902,1827],{"class":63},[53,1904,1905],{"class":119},"publishTask",[53,1907,1908],{"class":63},"(task, { filter: task.capability });\n",[15,1910,1911,1912,1916],{},"Two rules from the ",[436,1913,1915],{"href":1914},"/docs/concepts/filters","filters"," model apply here. A worker that subscribed without filters still receives filtered publishes, so unfiltered and filtered workers can coexist. With load balancing on, they should not: the broker treats the filtered and unfiltered subscriptions as separate share groups and a mixed pool delivers each task twice, so keep every worker in a group on the same filter shape.",[1918,1919,1920],"style",{},"html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":49,"searchDepth":77,"depth":77,"links":1922},[1923,1926,1929,1930,1933],{"id":26,"depth":77,"text":27,"children":1924},[1925],{"id":469,"depth":92,"text":470},{"id":575,"depth":77,"text":576,"children":1927},[1928],{"id":788,"depth":92,"text":789},{"id":847,"depth":77,"text":848},{"id":928,"depth":77,"text":929,"children":1931},[1932],{"id":1364,"depth":92,"text":1365},{"id":1458,"depth":77,"text":1459},"Reference guide for capabilities, priority, and custom tags in @nolag/agents, and how task routing actually works.","md",{},"/docs/agents/tags",{"title":5,"description":1934},"docs/agents/tags","NtzZooBdIvLDXOgNA_X12L8acIwDTx33oLY8ldnjkoI",1789869418628]