@lazyingart/agintiflow 0.20.336-integration.2 → 0.20.337-integration.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/aginti-work-examples/README.md +22 -0
  2. package/aginti-work-examples/deepseek-cli-fallback-20261001.md +73 -0
  3. package/bin/aginti-execution-worker.js +5 -0
  4. package/docs/deepseek-cli-fallback.md +134 -0
  5. package/docs/general-agent-backend-research-2026-09-27.md +213 -0
  6. package/docs/integration-deep-research.md +126 -1
  7. package/docs/integration-hosted-model.md +162 -0
  8. package/docs/public-pdf-acquisition.md +458 -0
  9. package/docs/supervision-campaign-ledger.md +81 -0
  10. package/package.json +37 -8
  11. package/scripts/eval-deepseek-cli.mjs +158 -0
  12. package/scripts/smoke-cli-chat.js +2 -0
  13. package/scripts/smoke-coding-tools.js +8 -0
  14. package/scripts/smoke-execution-worker-systemd-boundary.js +26 -0
  15. package/scripts/smoke-integration-analysis-api-server.js +31 -0
  16. package/scripts/smoke-integration-analysis-planner.js +866 -22
  17. package/scripts/smoke-integration-analysis-session-service.js +264 -9
  18. package/scripts/smoke-integration-api.js +10 -0
  19. package/scripts/smoke-integration-grounded-search.js +88 -1
  20. package/scripts/smoke-integration-model-binding.js +109 -0
  21. package/scripts/smoke-public-pdf-download.js +30 -0
  22. package/scripts/smoke-scs-evidence-visibility.js +11 -0
  23. package/scripts/smoke-truthful-completion.js +80 -0
  24. package/scripts/test-document-worker-fixture.js +4 -2
  25. package/src/agent-runner.js +26 -3
  26. package/src/cli.js +7 -2
  27. package/src/command-policy.js +18 -2
  28. package/src/config.js +5 -1
  29. package/src/engineering-guidance.js +1 -1
  30. package/src/execution-worker-systemd-boundary.js +28 -11
  31. package/src/integration-acquired-paper-contract.js +199 -0
  32. package/src/integration-acquired-paper-transfer.js +110 -0
  33. package/src/integration-analysis-cli.js +24 -3
  34. package/src/integration-analysis-config.js +114 -26
  35. package/src/integration-analysis-planner.js +494 -146
  36. package/src/integration-analysis-server.js +44 -12
  37. package/src/integration-analysis-session-service.js +536 -82
  38. package/src/integration-api.js +9 -5
  39. package/src/integration-document-worker-config.js +8 -1
  40. package/src/integration-document-worker-server.js +47 -2
  41. package/src/integration-document-worker-service.js +48 -0
  42. package/src/integration-file-worker-client.js +132 -4
  43. package/src/integration-file-worker-store.js +230 -155
  44. package/src/integration-grounded-search.js +57 -22
  45. package/src/integration-model-binding.js +123 -0
  46. package/src/integration-paper-acquisition-contract.js +131 -0
  47. package/src/integration-paper-acquisition.js +74 -0
  48. package/src/integration-paper-checkpoint.js +52 -0
  49. package/src/integration-paper-selection.js +65 -0
  50. package/src/integration-policy.js +27 -2
  51. package/src/integration-research-synthesis.js +80 -0
  52. package/src/model-client.js +50 -66
  53. package/src/provider-runtime.js +3 -2
  54. package/src/public-pdf-download.js +233 -0
  55. package/src/scs-evidence.js +4 -5
  56. package/test/cli-fallback-policy.test.js +109 -0
  57. package/test/fixtures/acquired-paper.js +48 -0
  58. package/test/fixtures/paper-download.js +37 -0
  59. package/test/fixtures/paper-recovery-child.js +38 -0
  60. package/test/fixtures/paper-recovery-runner.js +55 -0
  61. package/test/fixtures/paper-source.js +19 -0
  62. package/test/fixtures/paper-worker.js +32 -0
  63. package/test/integration-acquired-paper-http.test.js +261 -0
  64. package/test/integration-acquired-paper-session.test.js +232 -0
  65. package/test/integration-acquired-paper-store.test.js +370 -0
  66. package/test/integration-acquired-paper-transfer.test.js +83 -0
  67. package/test/integration-file-worker-cancellation.test.js +93 -0
  68. package/test/integration-independent-vision.test.js +141 -0
  69. package/test/integration-paper-acquisition.test.js +351 -0
  70. package/test/integration-paper-recovery.test.js +246 -0
  71. package/test/integration-paper-selection.test.js +60 -0
  72. package/test/integration-research-synthesis.test.js +111 -0
  73. package/test/integration-vision-inference.test.js +43 -0
  74. package/test/model-request-lifecycle.test.js +171 -0
  75. package/test/provider-runtime-private-health.test.js +64 -0
  76. package/test/public-pdf-download.test.js +266 -0
@@ -0,0 +1,22 @@
1
+ # AgInTiFlow Work Examples
2
+
3
+ This directory records supervised AgInTiFlow homework runs. It is not a generic demo gallery; each entry should include evidence that AgInTiFlow actually completed the task.
4
+
5
+ ## Rule
6
+
7
+ Do not record a task as complete only because the agent said it was complete. Each example needs durable proof such as:
8
+
9
+ - source files or commits,
10
+ - build/test logs,
11
+ - screenshots or PDFs,
12
+ - session id and tmux session name,
13
+ - artifact paths that still exist,
14
+ - notes about flaws found and AgInTiFlow upgrades made.
15
+
16
+ ## Current Examples
17
+
18
+ | Example | Profile | Status | Evidence |
19
+ | --- | --- | --- | --- |
20
+ | `android-tipsplit` | `android` + `auto` capability hardening | Verified | Android app built/tested/installed/launched; durable screenshot copied here |
21
+
22
+ Future runs should add a subfolder per task, plus a row in `homework-ledger.md`.
@@ -0,0 +1,73 @@
1
+ # DeepSeek CLI fallback acceptance — 2026-10-01
2
+
3
+ ## Scope
4
+
5
+ Improve everyday CLI work without a Codex wrapper: inspect files, create a
6
+ summary, repair a small project, run real tests, and continue the same session.
7
+ AgInTi performed all target-workspace edits through DeepSeek. The supervising
8
+ agent changed AgInTi itself, supplied synthetic fixtures and ordinary requests,
9
+ and independently checked outputs. No user's project was used as a test fixture.
10
+
11
+ The installed baseline was `0.20.331`. Development started from `486c56c`, which
12
+ already contained the undeployed request-lifecycle and read-only-input fixes on
13
+ top of integration `bf9c3e0`. The new release is `0.20.337-integration.0`, an opt-in
14
+ integration release rather than a promotion of the npm `latest` channel.
15
+
16
+ ## Failures were reproduced, not inferred
17
+
18
+ | Observation | Evidence | Repair or conclusion |
19
+ | --- | --- | --- |
20
+ | Baseline summary request temporarily changed `risks.txt` | Live Flash tool events showed an unwanted patch, a compensating restoration, and then the output; 8 model turns / 14 seconds | Deploy the existing source/output contract repair. The same request took 4 turns / 6 seconds and never edited either source. Timings are individual observations, not a benchmark. |
21
+ | Fast/manual selection silently ran Main | Offline config reproduced Flash becoming Pro, and an explicit DeepSeek manual model becoming a separately configured OpenAI main model | Keep the selected executor while retaining SCS planning and completion validation. |
22
+ | Could enable wrappers but could not explicitly disable them on resume | `--no-wrappers` was rejected; a stored true value had no matching negative CLI patch | Add symmetric parsing and durable resume support, including an ambient-true regression. |
23
+ | Retry could outlive its deadline | Earlier deterministic reproduction and eight lifecycle regressions | Include the previous cancellation/deadline repair; do not claim provider token generation became faster. |
24
+ | Final read-only discovery stopped an otherwise fixed task | A real `find` pipeline omitted `-maxdepth`; the CLI paused asking for broad host permission | Keep the command blocked but classify it as recoverable discovery. Preserve denial through pipelines/sequences. The same session continued and completed with unchanged permissions. |
25
+ | Optional inline JavaScript stopped a second restricted-host run | A compound `npm test; node -e ...` command was not admitted | Keep that host restriction. Describe host tool limits to the model and recommend Normal Docker workspace for general coding. Do not expand arbitrary host execution just to make a test pass. |
26
+ | The prompt itself encouraged unrelated cache searches | Engineering guidance suggested unbounded Python-cache discovery irrespective of stack | Use relevant-stack, bounded inspection and scoped claims; no unrelated cleanup requirement. |
27
+
28
+ The first Pro code fix passed its supplied tests, but an independent `10.075`
29
+ rounding example failed. A normal follow-up in the same session produced a
30
+ decimal-string repair and a new regression, passing the independent check. This
31
+ is useful evidence of resumability, and also a reminder that passing supplied
32
+ tests alone does not establish complete correctness. No money-specific patch was
33
+ added to AgInTi core.
34
+
35
+ ## Verification
36
+
37
+ - Full existing `npm test`: passed, with live provider-attribution probing off.
38
+ Existing occupied-port skips in document-worker checks remain skips, not passes
39
+ for those external services.
40
+ - Eight request-lifecycle regressions passed.
41
+ - Five new CLI routing/wrapper/discovery tests passed; the routing and discovery
42
+ reproductions failed before their repairs.
43
+ - Coding-tool policy, model-role, syntax, and CLI checks cover the changed paths.
44
+ - A denied discovery command is still denied. Mutating find actions, shell
45
+ execution, redirection, and destructive commands are not admitted by the repair.
46
+ - Live evaluator: `scripts/eval-deepseek-cli.mjs`. It retains each failed attempt
47
+ rather than overwriting it with a later pass. Its default follows the shipped
48
+ Normal Docker workspace; `AGINTIFLOW_EVAL_SANDBOX=host` exercises restricted host
49
+ behavior. A failed case exits nonzero.
50
+
51
+ Synthetic prompts, model results, events, independent test logs, and original
52
+ input hashes remain in a private acceptance directory. Credentials and raw
53
+ session history are not part of this public record or npm package.
54
+
55
+ The final fresh-workspace run passed all three cases with the Flash executor:
56
+
57
+ | Case | Model turns | Wall time | Independent result |
58
+ | --- | ---: | ---: | --- |
59
+ | Read two sources and write a summary | 5 | 9.1 s | Both sources unchanged; summary names both sources |
60
+ | Repair invoice utility and add regression coverage | 15 | 107.7 s | Project tests and 22 external oracle assertions passed |
61
+ | Resume for Chinese README instructions | 7 more | 17.3 s | Same session, next goal revision, implementation/tests byte-identical; tests and oracle still passed |
62
+
63
+ This is one successful run after the documented failures, not a success-rate or
64
+ speed claim. Model calls, planning, validation, and tool use all contribute to
65
+ wall time. No external Codex/Claude/Gemini agent wrapper was called. The existing
66
+ Docker image was reused; no GPU model, GUI desktop, or dependency rebuild was
67
+ needed. The test-created containers exited after each command.
68
+
69
+ ## Usage
70
+
71
+ See [DeepSeek CLI fallback](../docs/deepseek-cli-fallback.md) for start/resume,
72
+ permissions, model selection, and reproducible checks. No task is automatically
73
+ moved out of Codex when quota expires, and no Codex history is rewritten.
@@ -6,6 +6,11 @@ import {
6
6
  } from "../src/execution-worker-server.js";
7
7
 
8
8
  try {
9
+ if (Number.parseInt(process.versions.node, 10) < 22) {
10
+ throw Object.assign(new Error("The execution worker requires Node 22 or later."), {
11
+ code: "EXECUTION_WORKER_NODE_UNSUPPORTED",
12
+ });
13
+ }
9
14
  const config = await loadExecutionWorkerServerConfig();
10
15
  const runtime = await createProductionExecutionWorkerServer({ config });
11
16
  installExecutionWorkerShutdownHandlers(runtime.server);
@@ -0,0 +1,134 @@
1
+ # DeepSeek as a practical CLI fallback
2
+
3
+ Use AgInTiFlow for small coding, documentation, and workspace tasks when Codex is
4
+ unavailable. It runs its own tool loop with DeepSeek API credentials; a Codex
5
+ subscription or a working Codex CLI is not required. DeepSeek API usage has its
6
+ own billing and availability.
7
+
8
+ ## Start in the project you want to work on
9
+
10
+ Configure credentials once if needed:
11
+
12
+ ```bash
13
+ aginti auth deepseek
14
+ ```
15
+
16
+ From the project's terminal:
17
+
18
+ ```bash
19
+ aginti --provider deepseek --routing fast --no-wrappers
20
+ ```
21
+
22
+ Type an ordinary request, such as “Fix the failing tests and explain the change.”
23
+ The default Normal permission mode allows project edits and uses the Docker
24
+ workspace. It does not grant unrestricted host access. To use installed host
25
+ tools for a small, trusted project while keeping the existing command policy:
26
+
27
+ ```bash
28
+ aginti --provider deepseek --routing fast --no-wrappers --sandbox-mode host
29
+ ```
30
+
31
+ Host mode is not an OS sandbox. Commands still run as your user. Keep the project
32
+ scope narrow; use the Docker workspace when isolation is important. There is no
33
+ need to switch to Danger mode merely to read files, make patches, or run ordinary
34
+ tests. Arbitrary inline interpreter snippets can still stop in restricted host
35
+ mode; the normal Docker workspace is recommended for general coding. New
36
+ processes pick up an installed upgrade; no desktop reboot is needed.
37
+
38
+ One task, followed by a resumable exit:
39
+
40
+ ```bash
41
+ aginti run --provider deepseek --routing fast --no-wrappers \
42
+ "Read notes.txt and risks.txt. Write summary.md. Leave the inputs unchanged."
43
+ ```
44
+
45
+ Resume from the same project:
46
+
47
+ ```bash
48
+ aginti resume
49
+ aginti resume latest --no-wrappers
50
+ aginti resume SESSION_ID --no-wrappers "Continue and run the tests."
51
+ ```
52
+
53
+ AgInTi sessions and Codex sessions are separate. These commands resume AgInTi
54
+ history; they do not load a Codex JSONL file. For a quota handoff, leave a short
55
+ project note with the current task, files changed, checks already run, and next
56
+ step, then ask AgInTi to read it. Do not include account tokens or private keys.
57
+
58
+ To change a saved AgInTi session explicitly to DeepSeek Flash:
59
+
60
+ ```bash
61
+ aginti resume SESSION_ID --provider deepseek --model deepseek-v4-flash \
62
+ --routing manual --route-provider deepseek --route-model deepseek-v4-flash \
63
+ --main-provider deepseek --main-model deepseek-v4-pro \
64
+ --spare-provider deepseek --spare-model deepseek-v4-pro --no-wrappers
65
+ ```
66
+
67
+ Ordinary resume preserves saved runtime choices. An ambient environment change
68
+ does not silently switch the saved account/provider/model. `--no-wrappers`
69
+ explicitly disables Codex/Claude/Gemini-style external agent wrappers, including
70
+ when a saved session or environment previously enabled them. It does not disable
71
+ all shell commands or all separately configured external tools.
72
+
73
+ ## Model control and limits
74
+
75
+ - `--routing fast` keeps the fast executor, currently DeepSeek v4 Flash.
76
+ - `--routing manual --model MODEL` keeps that executor model.
77
+ - `--routing smart` retains automatic task routing and can choose Pro.
78
+ - Planning and completion validation remain active when the task requires them.
79
+ Their separately configured model roles may use Pro even with a Flash executor;
80
+ Fast does not mean every auxiliary request uses Flash.
81
+ - Default local-first routing is unchanged. The commands above explicitly choose
82
+ DeepSeek, rather than silently switching an existing local session to a cloud API.
83
+ - Review the diff and test results. A successful sample is not a promise of Codex
84
+ parity, error-free code, or completion of every task without follow-up.
85
+
86
+ ## Repairs in 0.20.337-integration.0
87
+
88
+ This integration build includes two earlier, previously undeployed fixes:
89
+
90
+ 1. The model compatibility retry shares the original deadline and cancellation
91
+ boundary. A stuck retry cannot keep AgInTi waiting beyond its deadline or
92
+ turn cancellation into a late success.
93
+ 2. Reading input files to create a separate output no longer forces mutations
94
+ to those inputs. Positive source-edit requests still require real edits.
95
+
96
+ It also adds:
97
+
98
+ 3. Fast/manual executor selection is preserved when SCS planning and evidence
99
+ validation activate. Previously these modes could silently run the main model,
100
+ including a separately configured provider.
101
+ 4. `--no-wrappers` works for a new run and as a persistent resume patch. Explicit
102
+ `--allow-wrappers` can still re-enable them.
103
+ 5. Syntactically read-only `find` without a depth bound remains **blocked**, but
104
+ returns a recoverable discovery error. The agent can choose structured file
105
+ tools or add a bounded `-maxdepth`, without asking for destructive permission.
106
+ That denial survives pipelines and command sequences. `-delete`, `-exec`,
107
+ file output, unknown shell segments, and other writes remain under the existing
108
+ stronger policies. No permission is silently granted and no denied command runs.
109
+
110
+ ## Reproduce the live acceptance check
111
+
112
+ This is opt-in, spends DeepSeek credits, and creates a new synthetic workspace.
113
+ It does not point the agent at your current project's source files.
114
+
115
+ ```bash
116
+ AGINTIFLOW_REAL_DEEPSEEK=1 npm run eval:deepseek-cli
117
+ ```
118
+
119
+ Optional: set `AGINTIFLOW_EVAL_ROOT` to a directory for retained private evidence,
120
+ or `AGINTIFLOW_EVAL_CLI` to an installed `bin/aginti-cli.js` to verify that package.
121
+ The default evaluation location is a fresh temporary directory. The evaluator
122
+ uses the default Normal Docker workspace; set `AGINTIFLOW_EVAL_SANDBOX=host` to
123
+ test the more restricted host policy instead. That is a distinct acceptance
124
+ configuration, and a blocked host run is not counted as a pass.
125
+
126
+ The evaluator checks a two-source summary, a small code repair with real tests,
127
+ and a Chinese README follow-up in the same session. Independent checks compare
128
+ input files, run tests again, exercise an external decimal-rounding oracle, verify
129
+ unchanged implementation/tests during the documentation follow-up, and inspect
130
+ actual model/tool events. Model summaries alone do not establish a pass. A failed
131
+ case produces a nonzero exit and a retained report; it is not relabeled successful.
132
+
133
+ See [the dated acceptance record](../aginti-work-examples/deepseek-cli-fallback-20261001.md)
134
+ for measured outcomes, failures encountered, and release/install details.
@@ -0,0 +1,213 @@
1
+ # General Agent Backend Research
2
+
3
+ Date: 2026-09-27. This is a source-based assessment plus an offline runtime
4
+ repair, not a production deployment or a live model-quality benchmark.
5
+
6
+ ## Baseline and Scope
7
+
8
+ - AgInTiFlow: `bf9c3e0386f86502246e776d25dcf29d43d89216`,
9
+ `integration/deepseek-analysis-20260910`, `0.20.336-integration.4`.
10
+ - Implementation branch: `fix/provider-request-lifecycle-20260927`, in
11
+ `AgInTiFlow-worktrees/AgInTiFlow-runtime-responsiveness`.
12
+ - AgenticApp reference HEAD: `7465ec7eece9ef92111ab28284fd7d54c2b2c8be`.
13
+ Its current source and handoffs were read; its unrelated dirty work was preserved.
14
+ - EchoMind reference HEAD: `190aeb3325dec6f5d31c56be80ed4f0b35d86f13`.
15
+ Its provider factory, conversation, voice, and single-flight code were read.
16
+ - No private conversation bodies, credentials, or model weights were required.
17
+ No application services, GPU jobs, provider defaults, or public routes were changed.
18
+
19
+ The existing SQLite campaign was opened read-only. It contains 69 capability
20
+ rows (6 passed, 63 passed-after-fix) and 114 test rows (8 passed, 104
21
+ passed-after-fix, 2 historical failures). Its latest recorded scenarios use
22
+ 0.20.331-era versions. This is substantial regression evidence, but does not
23
+ establish current integration performance or universal task coverage. The
24
+ new request-lifecycle regression is separate evidence, not a rewritten old pass.
25
+
26
+ ## What Already Works Architecturally
27
+
28
+ AgenticApp's `src/agenticapp/workspace_agent.py::run_aginti_turn` locks its
29
+ conversation registry, selects a persistent AgInTi session, and invokes the
30
+ machine CLI. `_run_aginti_provider_chain` preserves that session when changing
31
+ provider. `_parse_aginti_machine_result` treats stopped, failed, or unresolved
32
+ tool-protocol output as failure. The host registers actual artifact files;
33
+ an assistant mentioning a file is insufficient.
34
+
35
+ Its `references/aginti-primary-labcanvas-agent-handoff-2026-08-18.md` explicitly
36
+ assigns mature domain routines to their owning applications. This is the right
37
+ general boundary: AgInTi interprets, chooses tools, retains execution context,
38
+ and verifies completion. Applications own account policy, domain APIs, delivery,
39
+ and authorization of irreversible actions. Their chat names, schedules, and
40
+ private transport details should not enter AgInTi's core.
41
+
42
+ AgInTi already has mechanisms worth retaining:
43
+
44
+ | Need | Existing implementation | Validation used in this slice |
45
+ | --- | --- | --- |
46
+ | Provider handoff without restarting the task | `src/provider-handoff.js`, `src/agent-runner.js` | `smoke:provider-handoff` |
47
+ | Provider-aware context budgets | `src/context-budget-controller.js` | `smoke:context-budget-recovery` |
48
+ | Bounded tool disclosure and convergence | `src/progressive-tool-selection.js` | `eval:local-first-agent` |
49
+ | Persistent session, inbox, and crash replay | `src/session-store.js`, `src/session-runtime.js` | `smoke:session-runtime`, `smoke:runtime-core`, `smoke:inbox` |
50
+ | Evidence-backed completion | `src/scs-evidence.js`, `src/agent-runner.js` | `smoke:truthful-completion` |
51
+ | Scoped research, computation, documents, and artifacts | `src/integration-analysis-planner.js`, `src/integration-analysis-session-service.js` | `smoke:integration-analysis-planner` |
52
+ | Server-owned public authority | `src/integration-api.js`, `src/integration-auth.js`, `src/integration-policy.js` | Retain existing readiness and ownership gates |
53
+
54
+ The public analysis planner and the broad workspace runtime have different tool
55
+ surfaces. EchoMind must consume the declared public capability surface; it must
56
+ not assume that a CLI tool available on a developer workstation is a public
57
+ application capability.
58
+
59
+ ## Upstream Comparison
60
+
61
+ Existing clean reference checkouts were updated with fast-forward-only pulls,
62
+ with Git hooks and recursive submodule updates disabled. No upstream code was
63
+ copied into AgInTi and no upstream dependency installation was performed.
64
+
65
+ | Reference | Inspected revision | Relevant source and lesson |
66
+ | --- | --- | --- |
67
+ | OpenAI Codex | `41f9084b30812db321a0b592def4f500d1e79cf4` | `codex-rs/core/src/client.rs`, cancellation tokens and consumer-drop handling; `codex-rs/history/src/compaction_checkpoint.rs`, durable context boundaries |
68
+ | Claude Code | `7779afb12e3635f46f56ec823979d68350ae000b` | Public plugins and hook examples only; this checkout is not evidence of its proprietary runtime implementation |
69
+ | Gemini CLI | `2fe7c2d3f065dc40ad573d50b2091116f8a4aa18` | `packages/core/src/utils/retry.ts`, abort-aware retries; `packages/core/src/telemetry/`, stage-specific observations |
70
+ | Qwen Code | `36710ff6908c96a4b95db59c2f46c2b49278d02e` | `packages/core/src/utils/retry.ts`, cancellable delay and explicit retry policy |
71
+ | GitHub Copilot SDK | `d106d29dc6c5112da2abdae59008571b6692f12b` | `nodejs/src/session.ts::awaitWorkflowOperation`, guard before dispatch and abort race; `docs/features/session-persistence.md`, explicit session lifecycle |
72
+ | DeepSeek Harness | `99f6f02fecdb7dff40c3fbc9470f5907c29f74ca` | Pull timed out twice; existing `docs/agent-lifecycle.zh.md` describes durable session events separately from live coordination. This is a dated reference, not a verified current upstream snapshot. |
73
+
74
+ The reusable lesson is explicit lifecycle control, not more agents per task.
75
+ Anthropic's [context-engineering guidance](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents)
76
+ supports selective retrieval, small clear tool surfaces, and preserving important
77
+ state during compaction. AgInTi already implements parts of this; improve their
78
+ measured behavior before adding more prompts or parallel workers.
79
+
80
+ [Gemini's telemetry documentation](https://geminicli.com/docs/cli/telemetry/)
81
+ provides a useful reference for separating model, tool, and agent observations.
82
+ Apply that idea with private-content logging disabled, rather than copying a
83
+ telemetry service or transmitting user data.
84
+
85
+ ## Reproduced Defect and Implemented Repair
86
+
87
+ `src/model-client.js::createChatCompletion` bounded the first SDK call using
88
+ `Promise.race`, but awaited its unsupported-`reasoning_effort` compatibility
89
+ retry directly. The deadline still aborted a signal, yet the caller could remain
90
+ waiting and accept a late success. Caller cancellation similarly depended on
91
+ the client settling itself, rather than ending AgInTi's wait.
92
+
93
+ Before editing, a controlled client reproduced a retry still pending 80 ms after
94
+ a 25 ms deadline and then returning success. Eight deterministic tests were
95
+ added; six failed on the original source. A real OpenAI SDK instance with an
96
+ offline fetch implementation also reproduced the problem when the compatibility
97
+ retry entered a 429 Retry-After backoff. No provider request was transmitted.
98
+
99
+ The repair uses one shared deadline and cancellation outcome for both attempts:
100
+
101
+ - Already-cancelled work makes zero client calls.
102
+ - Caller cancellation ends the wait and sends abort to the transport.
103
+ - Both attempts share the original deadline; retry does not restart the clock.
104
+ - Late resolution cannot replace cancellation or timeout with success.
105
+ - Cancellation cannot trigger another compatibility attempt.
106
+ - Timers and parent listeners are removed after completion or failure.
107
+ - The optional compatibility retry, normal payloads, and provider-error metadata
108
+ remain intact. Existing timeout classification can still drive permitted
109
+ same-session handoff.
110
+
111
+ This improves a demonstrated waiting failure. It does not make the underlying
112
+ model generate tokens faster, guarantee a remote provider stopped computing,
113
+ or eliminate an SDK-owned backoff timer. The latter is drained in the regression
114
+ and cannot issue another fetch after abort. It also does not change the separate
115
+ public analysis planner's own model-request lifecycle.
116
+
117
+ ## Smallest EchoMind Integration
118
+
119
+ The inspected EchoMind `EchoMind/echomind/ai_client_factory.py` and
120
+ `mixed_ai_request.py` create provider clients. `voice_processor.py::get_ai_response`
121
+ uses schema-constrained responses, conversation context, and single-flight
122
+ deduplication; `process_audio` calls it through an executor. This is not yet a
123
+ durable AgInTi task interface, and replacing a provider URL cannot provide one.
124
+
125
+ Recommended boundary for a subsequent, separately tested integration:
126
+
127
+ ```mermaid
128
+ flowchart LR
129
+ UI[EchoMind chat or voice] --> BFF[Authenticated EchoMind backend]
130
+ BFF --> API[AgInTi versioned session and run API]
131
+ API --> Runtime[AgInTi policy, context, tools, evidence]
132
+ Runtime --> Workers[Admitted execution and artifact workers]
133
+ Runtime --> Models[Explicit permitted provider routes]
134
+ API --> Events[Durable public events and verified artifacts]
135
+ Events --> BFF
136
+ ```
137
+
138
+ Bind each user/conversation to an owned thread, preserve the same run/session
139
+ through reconnect and permitted provider handoff, and use mutation idempotency.
140
+ Use persisted run events for progress and replay. A stop request should cancel
141
+ the scoped run; a disconnected phone should not create a second task. Keep
142
+ speech recognition, TTS, language settings, notifications, and social features
143
+ in EchoMind. Add capabilities incrementally: text-only inference, source-backed
144
+ research, then admitted file/computation work.
145
+
146
+ `safe-chat` is a bounded stateless response service, not a substitute for this
147
+ session API. Its prose documentation predates the provider-general code, so
148
+ effective source configuration and capability probes must take precedence over
149
+ old DeepSeek-only examples. No EchoMind wiring or deployment was attempted here.
150
+
151
+ ## Prioritized Next Work
152
+
153
+ 1. **Measure latency without prompts in telemetry.** Correlate queue admission,
154
+ readiness, model attempts, retries, tools, validation, and terminal commit.
155
+ Existing `model.requested` events do not by themselves describe every SDK
156
+ attempt or first-token delay. Track p50/p95, request/tool counts, and repair
157
+ count per task class before claiming speed improvements.
158
+ 2. **Turn routine reuse into explicit capability contracts.** Reuse the existing
159
+ skill/profile/tool mechanisms. Domain owners provide bounded inputs, scope,
160
+ side-effect class, cancellation, output manifest, and verifier. The runtime
161
+ should not rediscover an entire repository after receiving an authoritative
162
+ routine that already answers the request.
163
+ 3. **Test the application adapter under real lifecycle failures.** Phone
164
+ reconnect, duplicate submit, cancellation, provider outage, worker restart,
165
+ ownership conflicts, and response loss must preserve one durable task and
166
+ verified outputs. Never replay a side-effecting tool turn as a fresh prompt.
167
+ 4. **Make perceived progress honest.** Expose stage and verified tool progress
168
+ early. If draft text is streamed later, mark it provisional and retain the
169
+ existing evidence gates before accepting a final answer or artifact.
170
+ 5. **Expand measured coverage, not permissions.** Reuse narrow application
171
+ routines for CAD, media, research, and documents. Unsupported host actions
172
+ should remain explicit capability limits. Worker readiness and optional-role
173
+ degradation must remain truthful.
174
+
175
+ Suggested acceptance prompts are ordinary, imperfect requests: summarize notes
176
+ without writing files; correct a prior answer in the same thread; inspect an
177
+ already-specified read-only routine; research a topic using both official web
178
+ and paper sources; calculate a result and create exactly the requested files;
179
+ cancel while a provider is retrying; reconnect after artifact commit without
180
+ repeating the work. Verify files and durable state from outside the agent.
181
+
182
+ No current live DeepSeek/LocalLLM latency or quality claim is made. Broad
183
+ production readiness still requires these app-level canaries and configured
184
+ capability proofs. A passing offline regression is evidence for its exact
185
+ contract, not a claim that all repositories or tasks now work perfectly.
186
+
187
+ ## Validation Record
188
+
189
+ - `node --test test/model-request-lifecycle.test.js`: 8 passed. Before the
190
+ repair, the same file produced 6 failures and 2 passes.
191
+ - `npm run smoke:model-roles`: passed, including the new regression file.
192
+ - `npm run smoke:provider-handoff`: passed with persisted mock-provider runs.
193
+ - Separate focused passes: `smoke:local-failure-recovery`,
194
+ `smoke:context-budget-recovery`, `smoke:session-runtime`, `smoke:runtime-core`,
195
+ `smoke:inbox`, `smoke:truthful-completion`, and
196
+ `smoke:integration-analysis-planner`.
197
+ - `npm run eval:local-first-agent`: 18 passed, 0 failed, 0 skipped;
198
+ its offline guard observed zero network attempts.
199
+ - `npm run check`: 300 JavaScript files passed. The new test file also passed
200
+ its explicit `node --check`.
201
+ - `AGINTIFLOW_PROVIDER_ATTRIBUTION_LIVE=0 npm test`: exit 0, including pretest.
202
+ The document-worker-server and document-worker-cross-boundary scripts
203
+ reported occupied-port skips for `127.0.0.1:18102`; its existing listener was
204
+ left untouched. These two HTTP checks are not claimed as executed passes.
205
+ - Dry-run npm packaging includes the new regression and excludes private
206
+ session, credential, database, and dependency paths in the inspected file list.
207
+ - `git diff --check`: passed.
208
+
209
+ Tests reused the baseline dependency installation through a temporary symlink;
210
+ no dependencies were installed or upgraded. Only task-owned smoke autostart
211
+ servers were stopped during cleanup. Package version remains
212
+ `0.20.336-integration.4`; no release, deployment, installed-package change, or
213
+ EchoMind/AgenticApp source change was performed.
@@ -4,6 +4,131 @@ The durable analysis API promotes only explicit deep-research instructions such
4
4
 
5
5
  An eligible run uses the private LazyEdge-bound LocalLLM task protocol at the exact `create`, `status`, and `cancel` routes. AgInTi fixes the model alias, limits the depth to `quick`, `standard`, or `deep`, polls one stable task identity, cancels incomplete work on abort, and accepts only bounded no-cache responses. Exact domain, DOI, arXiv, and image-grounded requests retain the stricter one-shot Search path instead of weakening their constraints.
6
6
 
7
- The completed report is accepted only with at least one safe source and valid one-based citations. Every source is preserved in one authority-bound `sources` artifact. A pure research request returns that validated report directly; a combined document, file, or execution request carries it forward as untrusted evidence for the remaining agent work.
7
+ Ranked deep research uses the same optional, tool-free topic selection as quick
8
+ Search: at most six verbatim fragments of the current request, persisted before
9
+ dispatch and reused on resume. Topic/filters stay separate from later calculation,
10
+ coding or file-creation actions. The selected query is the actual upstream task
11
+ question, not only an artifact label; a short subject uses the service-owned
12
+ prefix `Research on` to meet the existing question-length contract. Invalid
13
+ selection keeps the original bounded query. No private history is provided to
14
+ the selector, and exact identifier/domain constraints retain their authority.
15
+ The original request still governs all remaining execution and output work.
16
+
17
+ The completed report is accepted only with at least one safe source and valid one-based citations. Every source is preserved in one authority-bound `sources` artifact. A pure research request returns a successful validated report directly; a combined document, file, or execution request carries it forward as untrusted evidence for the remaining agent work.
18
+
19
+ If the upstream service explicitly declares its terminal result an evidence
20
+ inventory, AgInTi makes one optional synthesis attempt with the selected model.
21
+ It receives only the current public research question and validated source
22
+ titles/snippets, with no previous conversation, tools, raw pages or credentials.
23
+ The synthesis prompt explicitly takes answer language from the original current
24
+ question or its requested language, never from source language or JSON examples.
25
+ There is no extra search, model escalation or repair loop. A successful report
26
+ is never rewritten, and an inventory with no usable snippets costs no model call.
27
+
28
+ The recovery reply uses a small JSON claim/evidence schema. Every finding must
29
+ cite a current source with a verbatim supporting snippet excerpt; indices,
30
+ quote containment, output size and plain-text presentation are checked before
31
+ the application renders citation markers. The result is explicitly labeled a
32
+ retrieved-evidence summary, not a full-paper review. These are provenance and
33
+ structure checks, not entailment verification. Source text stays untrusted.
34
+ Model quota, timeout, malformed/truncated output, context overflow, or rejected
35
+ evidence leaves the original inventory and all source cards intact; cancellation
36
+ still cancels the run. Compound tasks retain the accepted summary alongside
37
+ their separately verified results. Other providers and shared LocalLLM services
38
+ keep their configured defaults.
39
+
40
+ Coordinated computation requests use the same action matcher as standalone
41
+ requests. For example, research followed by “Then use Python to calculate…”
42
+ retains an execution obligation, including after earlier conversation. Quoted,
43
+ historical, explanatory and negated clauses remain non-executing. The research
44
+ report cannot finalize such a compound run before the requested execution.
45
+
46
+ Research depth comes from a modifier immediately before the research directive:
47
+ “quick deep research” is quick, whereas research about short sequences or
48
+ standard algorithms remains deep. Multiline chat whitespace is normalized when
49
+ deriving the one-line provider query; other control characters, length bounds,
50
+ exact identifiers and source/domain constraints retain their existing checks.
51
+
52
+ Completed compound requests preserve the validated research report as a distinct
53
+ part of the final answer, followed by the remaining task results. The report is
54
+ not disposable synthesis context: numeric/citation repair and tight-context
55
+ fallbacks retain both research and verified execution output. A calculation-only
56
+ summary needs no artificial research citation; any supplied citation must still
57
+ refer to a current source, and evidence-denial/numeric checks remain enforced.
58
+ This uses the existing final-response and durable callback contract, with no
59
+ extra model call or new artifact kind. The report remains untrusted text, never
60
+ tool authorization, and is scoped to this run only.
61
+
62
+ The existing bounded chat response reserves space for both result sections and
63
+ capability notices. If a section exceeds its allocation, the UTF-8-safe excerpt
64
+ is explicitly marked as shortened. This is a chat presentation, not a promise
65
+ of full-length document retention or proof that every research claim is correct.
66
+ Long-form document delivery and source-relevance qualification remain separate.
67
+
68
+ Artifact privacy checks distinguish standalone slash operators followed only by
69
+ sentence punctuation from actual path-like tokens. Public mathematical prose
70
+ such as an operator list may contain the former. Unix paths with filename text,
71
+ file URLs, Windows drive paths and UNC paths retain their existing treatment;
72
+ this lexical correction does not authorize filesystem access or expose a path.
8
73
 
9
74
  Search/research intent, task activity, artifacts, failures, and terminal state use the same durable session ledger as other Agent work. The next message in the thread does not inherit stale research authority or completed activity. Public capabilities advertise the optional `localllm/research-task/v2` protocol while retaining the original Search contract for older Web clients.
75
+
76
+ ## Explicit application search policy
77
+
78
+ Applications that send private conversation history can set
79
+ `input.searchInference: false` on `runs/start` or an input-bearing `runs/resume`.
80
+ This prevents text (including quoted historical requests) from implicitly
81
+ enabling grounded search or deep research. Omission or `true` retains the
82
+ existing natural-language inference behavior. Only boolean values are accepted.
83
+
84
+ An explicit `input.search: {mode: "web" | "papers" | "both", limit: 1..20}`
85
+ still selects bounded search when inference is off. The application should
86
+ provide its separately authorized public query in that phase, rather than
87
+ forwarding private history to a search tool.
88
+
89
+ The disabled-inference choice is persisted and bound to the run's authority
90
+ snapshot. An input-less resume preserves it across restart/retry. A new input
91
+ selects its own policy, so a subsequent normal request is not accidentally
92
+ restricted by an older private phase. This is tool-routing policy; the hosted
93
+ model still receives the input submitted to it, and worker sandbox/network
94
+ controls remain separate.
95
+
96
+ ## Text-only application inference
97
+
98
+ For a private routing decision or title, pass
99
+ `input.inference: {responseFormat: "json_object"}` (or `"text"`). This is a
100
+ separate, explicit capability: the planner makes one model completion with no
101
+ tools, before task classification, search, document revision or execution.
102
+ Structured tool-call responses are rejected; quoted tool instructions and code
103
+ examples remain text. JSON output must be a complete object. Applications still
104
+ validate their own response schema.
105
+
106
+ Text-only inference cannot be combined with search, attachments or enabled
107
+ search inference. It has no retained artifact/image inputs or document lineage, and
108
+ session callbacks cannot issue or commit files. The immutable choice survives
109
+ restart and input-less retry; a new input selects its own policy. Normal runs
110
+ without this field keep their existing tool capabilities. The chosen hosted
111
+ model receives the inference input, so this is tool isolation, not an on-device
112
+ privacy promise.
113
+
114
+ ### Explicit image-aware inference
115
+
116
+ An application may opt a private routing step into local perception with
117
+ `input.inference: {responseFormat: "json_object", vision: true}` and the normal
118
+ bounded `input.attachments` image descriptors. Require the live
119
+ `attachments.inferenceVision === true` capability before using this extension.
120
+ Old capabilities remain readable and do not imply support. The flag appears
121
+ only while the independent local vision role and retained-image store are ready.
122
+
123
+ Pixels go to the local vision role. Its validated observations are passed to
124
+ the configured text model as untrusted data, with tools, search, execution and
125
+ file access still disabled. Returned tool calls are protocol errors. This does
126
+ not promise that image-derived observations remain on-device when the text
127
+ provider is hosted. Applications validate their own JSON decision schema.
128
+
129
+ The choice is durable. Input-less retry of an image-aware run requires
130
+ `reuseAttachments: true` and reuses the same immutable image references. A new
131
+ text-only inference ignores retained images and remains available without the
132
+ optional vision role. Vision opt-in without any current/reused image fails
133
+ before inference. Explicit/inferred public search and artifact/document lineage
134
+ remain separate, and session callbacks cannot create or commit files.