Skip to content

Commit ccee955

Browse files
Add regression for constructor llm getter traps
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent af80424 commit ccee955

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎currentState.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ HyperAgent exposes a TypeScript SDK for browser automation with three primary pa
139139
- Expanded cached-action helper regression coverage to validate trap-safe option access (`cdpActions`, `filterAdTrackingFrames`, `maxSteps`) with deterministic fallback to agent/default settings.
140140
- Hardened constructor-wide config ingestion (LLM/provider/debug/options/custom-actions/local/hyper configs) with trap-safe reads and sane defaults so malformed/trap-prone config objects no longer crash initialization.
141141
- Hardened open-tab prompt materialization with trap-safe tab-array reads so unreadable tab entries are skipped and summarized instead of collapsing to unavailable output.
142+
- Added constructor regression coverage for trap-prone `llm` config getters, ensuring fallback failure paths stay deterministic and readable.
142143
- Expanded top-level package exports for key workflow/config types at `@hyperbrowser/agent`.
143144
- Removed stale script entry (`build-dom-tree-script`) and improved README usage docs.
144145
- Added canonical single-action debug writer helper (`writePerformDebug`) while preserving deprecated alias compatibility.

‎src/agent/__tests__/hyperagent-constructor.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,34 @@ describe("HyperAgent constructor and task controls", () => {
106106
expect(getDebugOptions().enabled).toBe(false);
107107
});
108108

109+
it("throws readable missing-provider error when llm getter traps", () => {
110+
const previousKey = process.env.OPENAI_API_KEY;
111+
delete process.env.OPENAI_API_KEY;
112+
try {
113+
const trappedConfig = new Proxy(
114+
{},
115+
{
116+
get: (_target, prop: string | symbol) => {
117+
if (prop === "llm") {
118+
throw new Error("llm getter trap");
119+
}
120+
return undefined;
121+
},
122+
}
123+
) as unknown as ConstructorParameters<typeof HyperAgent>[0];
124+
125+
expect(() => new HyperAgent(trappedConfig)).toThrow(
126+
"No LLM provider provided"
127+
);
128+
} finally {
129+
if (typeof previousKey === "undefined") {
130+
delete process.env.OPENAI_API_KEY;
131+
} else {
132+
process.env.OPENAI_API_KEY = previousKey;
133+
}
134+
}
135+
});
136+
109137
it("throws synchronously for reserved custom action names", () => {
110138
const reservedAction: AgentActionDefinition = {
111139
type: "complete",

0 commit comments

Comments
 (0)