little-coder 1.8.1 → 1.8.2
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.
- package/.pi/extensions/benchmark-profiles/index.ts +24 -0
- package/.pi/extensions/benchmark-profiles/profiles.test.ts +53 -0
- package/.pi/extensions/llama-cpp-provider/config.test.ts +116 -0
- package/.pi/extensions/llama-cpp-provider/config.ts +33 -0
- package/CHANGELOG.md +11 -0
- package/package.json +1 -1
|
@@ -163,10 +163,29 @@ function toLittleCoderOptions(p: ModelProfile): Record<string, unknown> {
|
|
|
163
163
|
return out;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
// Providers whose servers accept a `temperature` field on chat-completions.
|
|
167
|
+
// little-coder's temperature defaults are tuned for the local-server case;
|
|
168
|
+
// hosted reasoning models (Copilot's gpt-5.x, OpenAI o-series) hard-reject
|
|
169
|
+
// the parameter with a 400 (issue #33). The list is intentionally minimal:
|
|
170
|
+
// llama.cpp-style local servers. Override at runtime via
|
|
171
|
+
// LITTLE_CODER_TEMPERATURE_PROVIDERS=foo,bar to add your own local provider.
|
|
172
|
+
const DEFAULT_TEMPERATURE_PROVIDERS = ["llamacpp", "ollama", "lmstudio"] as const;
|
|
173
|
+
|
|
174
|
+
export function providerAcceptsTemperature(provider: string, env: NodeJS.ProcessEnv = process.env): boolean {
|
|
175
|
+
const override = env.LITTLE_CODER_TEMPERATURE_PROVIDERS;
|
|
176
|
+
const list = override
|
|
177
|
+
? override.split(",").map((s) => s.trim()).filter(Boolean)
|
|
178
|
+
: (DEFAULT_TEMPERATURE_PROVIDERS as readonly string[]);
|
|
179
|
+
return list.includes(provider);
|
|
180
|
+
}
|
|
181
|
+
|
|
166
182
|
export default function (pi: ExtensionAPI) {
|
|
167
183
|
// Shared across handlers so before_provider_request can re-read the most
|
|
168
184
|
// recently resolved temperature without re-parsing settings every turn.
|
|
169
185
|
let resolvedTemperature: number | undefined;
|
|
186
|
+
// Provider-level guard: hosted reasoning models reject `temperature` (see
|
|
187
|
+
// DEFAULT_TEMPERATURE_PROVIDERS above).
|
|
188
|
+
let temperatureAccepted = false;
|
|
170
189
|
|
|
171
190
|
pi.on("before_agent_start", async (event, ctx) => {
|
|
172
191
|
const model = ctx.model;
|
|
@@ -193,6 +212,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
193
212
|
opts.littleCoder.contextLimit = resolveContextLimit(profile.context_limit, modelWindow);
|
|
194
213
|
|
|
195
214
|
resolvedTemperature = opts.littleCoder.temperature;
|
|
215
|
+
temperatureAccepted = providerAcceptsTemperature(model.provider);
|
|
196
216
|
});
|
|
197
217
|
|
|
198
218
|
// Inject the profile's temperature onto the outgoing provider payload.
|
|
@@ -200,10 +220,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
200
220
|
// llama.cpp), which adds measurable stochastic variance on hard
|
|
201
221
|
// algorithmic exercises. Matches local-coder's profiles[].temperature=0.3.
|
|
202
222
|
//
|
|
223
|
+
// Skipped for providers whose servers reject `temperature` (Copilot's
|
|
224
|
+
// gpt-5.x, OpenAI's o-series) — see providerAcceptsTemperature.
|
|
225
|
+
//
|
|
203
226
|
// IMPORTANT: pi's runner passes payload by reference but only adopts
|
|
204
227
|
// *returned* values. Mutating in place is discarded between handlers, so
|
|
205
228
|
// we build a new payload object and return it explicitly.
|
|
206
229
|
pi.on("before_provider_request", async (event) => {
|
|
230
|
+
if (!temperatureAccepted) return;
|
|
207
231
|
if (resolvedTemperature === undefined) return;
|
|
208
232
|
const payload: any = (event as any).payload;
|
|
209
233
|
if (!payload || typeof payload !== "object") return;
|
|
@@ -7,6 +7,7 @@ import benchmarkProfiles, {
|
|
|
7
7
|
normKey,
|
|
8
8
|
resolveContextLimit,
|
|
9
9
|
CONTEXT_FALLBACK,
|
|
10
|
+
providerAcceptsTemperature,
|
|
10
11
|
} from "./index.ts";
|
|
11
12
|
|
|
12
13
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
@@ -148,3 +149,55 @@ describe("before_agent_start publishes a model-window contextLimit", () => {
|
|
|
148
149
|
expect(lc.contextLimit).toBe(65536);
|
|
149
150
|
});
|
|
150
151
|
});
|
|
152
|
+
|
|
153
|
+
describe("providerAcceptsTemperature (issue #33)", () => {
|
|
154
|
+
it("accepts the shipped local providers by default", () => {
|
|
155
|
+
expect(providerAcceptsTemperature("llamacpp", {})).toBe(true);
|
|
156
|
+
expect(providerAcceptsTemperature("ollama", {})).toBe(true);
|
|
157
|
+
expect(providerAcceptsTemperature("lmstudio", {})).toBe(true);
|
|
158
|
+
});
|
|
159
|
+
it("rejects hosted reasoning providers that 400 on temperature", () => {
|
|
160
|
+
expect(providerAcceptsTemperature("copilot", {})).toBe(false);
|
|
161
|
+
expect(providerAcceptsTemperature("openai", {})).toBe(false);
|
|
162
|
+
expect(providerAcceptsTemperature("anthropic", {})).toBe(false);
|
|
163
|
+
});
|
|
164
|
+
it("LITTLE_CODER_TEMPERATURE_PROVIDERS env replaces the default list", () => {
|
|
165
|
+
const env = { LITTLE_CODER_TEMPERATURE_PROVIDERS: "vllm, my-local" };
|
|
166
|
+
expect(providerAcceptsTemperature("vllm", env)).toBe(true);
|
|
167
|
+
expect(providerAcceptsTemperature("my-local", env)).toBe(true);
|
|
168
|
+
expect(providerAcceptsTemperature("llamacpp", env)).toBe(false);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe("before_provider_request only injects temperature for accepting providers", () => {
|
|
173
|
+
async function runHandlers(model: any, payload: any) {
|
|
174
|
+
const handlers: Record<string, ((e: any, c: any) => any)[]> = {};
|
|
175
|
+
const pi = { on: (n: string, h: any) => ((handlers[n] ??= []).push(h)) };
|
|
176
|
+
benchmarkProfiles(pi as any);
|
|
177
|
+
const startEvent: any = { systemPromptOptions: {} };
|
|
178
|
+
const ctx: any = { model };
|
|
179
|
+
for (const h of handlers["before_agent_start"] ?? []) await h(startEvent, ctx);
|
|
180
|
+
const reqEvent: any = { payload };
|
|
181
|
+
let lastResult: any;
|
|
182
|
+
for (const h of handlers["before_provider_request"] ?? []) {
|
|
183
|
+
lastResult = await h(reqEvent, ctx);
|
|
184
|
+
}
|
|
185
|
+
return lastResult;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
it("injects temperature for a local llamacpp model", async () => {
|
|
189
|
+
const out = await runHandlers(
|
|
190
|
+
{ provider: "llamacpp", id: "qwen3.6-27b", contextWindow: 131072 },
|
|
191
|
+
{ messages: [] },
|
|
192
|
+
);
|
|
193
|
+
expect(out).toMatchObject({ temperature: 0.3 });
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("does NOT inject temperature for copilot/gpt-5.x (issue #33)", async () => {
|
|
197
|
+
const out = await runHandlers(
|
|
198
|
+
{ provider: "copilot", id: "gpt-5.4", contextWindow: 131072 },
|
|
199
|
+
{ messages: [] },
|
|
200
|
+
);
|
|
201
|
+
expect(out).toBeUndefined();
|
|
202
|
+
});
|
|
203
|
+
});
|
|
@@ -5,6 +5,7 @@ import { dirname, join, resolve } from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import {
|
|
7
7
|
applyEnvOverrides,
|
|
8
|
+
fillModelDefaults,
|
|
8
9
|
loadProviders,
|
|
9
10
|
mergeProviders,
|
|
10
11
|
resolveOverridePath,
|
|
@@ -195,6 +196,121 @@ describe("shipped models.json", () => {
|
|
|
195
196
|
});
|
|
196
197
|
});
|
|
197
198
|
|
|
199
|
+
describe("fillModelDefaults (issue #36)", () => {
|
|
200
|
+
// The crash was: a user models.json entry that omitted name/maxTokens/cost
|
|
201
|
+
// reached pi's registry as `model.cost === undefined`, which then exploded
|
|
202
|
+
// with "Cannot read properties of undefined (reading 'input')" deep in
|
|
203
|
+
// applyModelOverride. Filling the same defaults pi uses internally lets a
|
|
204
|
+
// minimal entry round-trip safely.
|
|
205
|
+
it("fills name/maxTokens/cost/input/contextWindow/reasoning when missing", () => {
|
|
206
|
+
const out = fillModelDefaults({ id: "foo.gguf" }, "llamacpp", 0);
|
|
207
|
+
expect(out).toMatchObject({
|
|
208
|
+
id: "foo.gguf",
|
|
209
|
+
name: "foo.gguf",
|
|
210
|
+
reasoning: false,
|
|
211
|
+
input: ["text"],
|
|
212
|
+
contextWindow: 32768,
|
|
213
|
+
maxTokens: 4096,
|
|
214
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it("preserves user-supplied values over defaults", () => {
|
|
219
|
+
const out = fillModelDefaults(
|
|
220
|
+
{
|
|
221
|
+
id: "Qwen3.6-27B-Q4_K_M.gguf",
|
|
222
|
+
reasoning: true,
|
|
223
|
+
input: ["text", "image"],
|
|
224
|
+
contextWindow: 262144,
|
|
225
|
+
},
|
|
226
|
+
"llamacpp",
|
|
227
|
+
0,
|
|
228
|
+
);
|
|
229
|
+
expect(out.reasoning).toBe(true);
|
|
230
|
+
expect(out.input).toEqual(["text", "image"]);
|
|
231
|
+
expect(out.contextWindow).toBe(262144);
|
|
232
|
+
// Still defaulted:
|
|
233
|
+
expect(out.maxTokens).toBe(4096);
|
|
234
|
+
expect(out.cost).toEqual({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("preserves unknown extra fields (e.g. _launch)", () => {
|
|
238
|
+
const out: any = fillModelDefaults({ id: "x", _launch: true }, "llamacpp", 0);
|
|
239
|
+
expect(out._launch).toBe(true);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it("throws with a precise pointer when id is missing", () => {
|
|
243
|
+
expect(() => fillModelDefaults({}, "llamacpp", 2)).toThrow(/provider 'llamacpp' model at index 2/);
|
|
244
|
+
expect(() => fillModelDefaults({ id: "" }, "llamacpp", 0)).toThrow(/missing or invalid "id"/);
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
describe("loadProviders with an under-specified user override (issue #36)", () => {
|
|
249
|
+
let dir: string;
|
|
250
|
+
beforeEach(() => {
|
|
251
|
+
dir = mkdtempSync(join(tmpdir(), "lc-providers36-"));
|
|
252
|
+
});
|
|
253
|
+
afterEach(() => {
|
|
254
|
+
rmSync(dir, { recursive: true, force: true });
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it("a minimal user model entry no longer leaves cost undefined", () => {
|
|
258
|
+
writeFileSync(join(dir, "models.json"), JSON.stringify({ providers: {} }));
|
|
259
|
+
const userPath = join(dir, "user.json");
|
|
260
|
+
writeFileSync(
|
|
261
|
+
userPath,
|
|
262
|
+
JSON.stringify({
|
|
263
|
+
providers: {
|
|
264
|
+
llamacpp: {
|
|
265
|
+
api: "openai-completions",
|
|
266
|
+
apiKey: "llama",
|
|
267
|
+
baseUrl: "http://127.0.0.1:8020/v1",
|
|
268
|
+
models: [
|
|
269
|
+
{
|
|
270
|
+
_launch: true,
|
|
271
|
+
contextWindow: 262144,
|
|
272
|
+
id: "Qwen3.6-27B-Q4_K_M.gguf",
|
|
273
|
+
input: ["text", "image"],
|
|
274
|
+
reasoning: true,
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
}),
|
|
280
|
+
);
|
|
281
|
+
const result = loadProviders(dir, { LITTLE_CODER_MODELS_FILE: userPath });
|
|
282
|
+
const m = result.providers.llamacpp.models[0];
|
|
283
|
+
expect(m.cost).toEqual({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
|
|
284
|
+
expect(m.maxTokens).toBe(4096);
|
|
285
|
+
expect(m.name).toBe("Qwen3.6-27B-Q4_K_M.gguf");
|
|
286
|
+
// User-supplied values must win:
|
|
287
|
+
expect(m.contextWindow).toBe(262144);
|
|
288
|
+
expect(m.input).toEqual(["text", "image"]);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it("a model entry without an id is reported as invalid, not silently passed through", () => {
|
|
292
|
+
writeFileSync(join(dir, "models.json"), JSON.stringify({ providers: {} }));
|
|
293
|
+
const userPath = join(dir, "user.json");
|
|
294
|
+
writeFileSync(
|
|
295
|
+
userPath,
|
|
296
|
+
JSON.stringify({
|
|
297
|
+
providers: {
|
|
298
|
+
llamacpp: {
|
|
299
|
+
api: "openai-completions",
|
|
300
|
+
apiKey: "k",
|
|
301
|
+
baseUrl: "http://x/v1",
|
|
302
|
+
models: [{ reasoning: true }],
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
}),
|
|
306
|
+
);
|
|
307
|
+
const result = loadProviders(dir, { LITTLE_CODER_MODELS_FILE: userPath });
|
|
308
|
+
const userSrc = result.sources.find((s) => s.path === userPath);
|
|
309
|
+
expect(userSrc?.status).toBe("invalid");
|
|
310
|
+
expect(userSrc?.error).toMatch(/missing or invalid "id"/);
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
|
|
198
314
|
describe("propsUrlFor", () => {
|
|
199
315
|
it("strips a trailing /v1 and points at the server root /props", () => {
|
|
200
316
|
expect(propsUrlFor("http://127.0.0.1:8888/v1")).toBe("http://127.0.0.1:8888/props");
|
|
@@ -67,9 +67,42 @@ function parseModelsFile(raw: string): ModelsFile {
|
|
|
67
67
|
if (!parsed || typeof parsed !== "object" || !parsed.providers || typeof parsed.providers !== "object") {
|
|
68
68
|
throw new Error("expected top-level { providers: { ... } }");
|
|
69
69
|
}
|
|
70
|
+
const providers = parsed.providers as Record<string, ProviderEntry>;
|
|
71
|
+
for (const [name, entry] of Object.entries(providers)) {
|
|
72
|
+
if (!entry || typeof entry !== "object" || !Array.isArray(entry.models)) continue;
|
|
73
|
+
entry.models = entry.models.map((m, i) => fillModelDefaults(m, name, i));
|
|
74
|
+
}
|
|
70
75
|
return parsed as ModelsFile;
|
|
71
76
|
}
|
|
72
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Fill in defaults for optional model fields that pi requires downstream.
|
|
80
|
+
* pi's `registerProvider` path stores model entries verbatim, so a user
|
|
81
|
+
* override that omits e.g. `cost` ends up with `model.cost === undefined`,
|
|
82
|
+
* and the model registry's per-model override path crashes with
|
|
83
|
+
* "Cannot read properties of undefined (reading 'input')" (issue #36) when
|
|
84
|
+
* it tries to read `model.cost.input`. Filling the same defaults pi uses
|
|
85
|
+
* for built-in models means a minimal user entry — just an id — works.
|
|
86
|
+
*
|
|
87
|
+
* The `id` field is the only true requirement. We throw with a precise
|
|
88
|
+
* pointer when it's missing so the caller can route this to the source-list
|
|
89
|
+
* diagnostics rather than crashing pi.
|
|
90
|
+
*/
|
|
91
|
+
export function fillModelDefaults(m: any, providerName: string, index: number): ProviderModelEntry {
|
|
92
|
+
if (!m || typeof m !== "object" || typeof m.id !== "string" || m.id.length === 0) {
|
|
93
|
+
throw new Error(`provider '${providerName}' model at index ${index}: missing or invalid "id"`);
|
|
94
|
+
}
|
|
95
|
+
const defaults = {
|
|
96
|
+
name: m.id,
|
|
97
|
+
reasoning: false,
|
|
98
|
+
input: ["text"] as ("text" | "image")[],
|
|
99
|
+
contextWindow: 32768,
|
|
100
|
+
maxTokens: 4096,
|
|
101
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
102
|
+
};
|
|
103
|
+
return { ...defaults, ...m };
|
|
104
|
+
}
|
|
105
|
+
|
|
73
106
|
function readIfPresent(path: string): { kind: "ok"; data: ModelsFile } | { kind: "missing" } | { kind: "invalid"; error: string } {
|
|
74
107
|
if (!existsSync(path)) return { kind: "missing" };
|
|
75
108
|
try {
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to little-coder are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and little-coder's public interface (CLI, providers, tools, skills) follows semver starting at `v0.0.1` post-rename.
|
|
4
4
|
|
|
5
|
+
## [v1.8.2] — 2026-05-25
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **Minimal user `models.json` entries no longer crash startup with `Cannot read properties of undefined (reading 'input')`** ([#36](https://github.com/itayinbarr/little-coder/issues/36)). The shipped `models.json` declares every field — `id`, `name`, `reasoning`, `input`, `contextWindow`, `maxTokens`, `cost` — but a user override that omitted e.g. `name`/`maxTokens`/`cost` was passed through unchanged to pi's registry, which then exploded deep in `applyModelOverride` when it tried to read `model.cost.input`. `llama-cpp-provider` now fills in the same defaults pi uses for built-in models (`name = id`, `reasoning = false`, `input = ["text"]`, `contextWindow = 32768`, `maxTokens = 4096`, zero-cost) so a minimal entry — just `id` plus the provider's `baseUrl`/`apiKey` — works. User-supplied values still win over defaults; unknown extra fields (e.g. `_launch`) are preserved. A model entry that omits `id` is now flagged with a precise error in the source diagnostics instead of crashing pi. New `fillModelDefaults` helper, plus regression tests using the exact entry shape from the issue report.
|
|
9
|
+
- **`temperature' is not supported with this model` against Copilot GPT-5.x / OpenAI o-series** ([#33](https://github.com/itayinbarr/little-coder/issues/33)). `benchmark-profiles` was injecting `temperature: 0.3` from `default_model_profile` into every outgoing chat-completions payload, but hosted reasoning models hard-reject the parameter with a 400. The temperature injection is now gated on the provider: it ships on for `llamacpp`, `ollama`, and `lmstudio` (the providers it was tuned for) and is skipped for everything else. New env var `LITTLE_CODER_TEMPERATURE_PROVIDERS=foo,bar` replaces the default list when you bring your own local provider (e.g. `vllm`). New exported, tested `providerAcceptsTemperature()`; end-to-end test fires `before_agent_start` + `before_provider_request` and asserts the copilot path returns no payload mutation.
|
|
10
|
+
|
|
11
|
+
### Notes for upgraders
|
|
12
|
+
- No CLI-flag or public-API changes. If you previously relied on temperature 0.3 reaching a non-local provider via the default profile (uncommon — most hosted providers reject it), add that provider name to `LITTLE_CODER_TEMPERATURE_PROVIDERS`.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
5
16
|
## [v1.8.1] — 2026-05-23
|
|
6
17
|
|
|
7
18
|
### Fixed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "little-coder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "A pi-based coding agent optimized for small local language models. Reproduces the whitepaper's scaffold-model-fit adaptations as pi extensions.",
|
|
5
5
|
"homepage": "https://github.com/itayinbarr/little-coder",
|
|
6
6
|
"repository": {
|