Skip to content

Commit f0c6dce

Browse files
don't autowrap getters on an agent (#434)
1 parent 1e4188c commit f0c6dce

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.changeset/orange-bars-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"agents": patch
3+
---
4+
5+
don't autowrap getters on an agent

packages/agents/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,11 +850,12 @@ export class Agent<Env = typeof env, State = unknown> extends Server<Env> {
850850
while (proto && proto !== Object.prototype && depth < 10) {
851851
const methodNames = Object.getOwnPropertyNames(proto);
852852
for (const methodName of methodNames) {
853-
// Skip if it's a private method or not a function
853+
// Skip if it's a private method or not a function or a getter
854854
if (
855855
baseMethods.has(methodName) ||
856856
methodName.startsWith("_") ||
857-
typeof this[methodName as keyof this] !== "function"
857+
typeof this[methodName as keyof this] !== "function" ||
858+
!!Object.getOwnPropertyDescriptor(proto, methodName)?.get
858859
) {
859860
continue;
860861
}

0 commit comments

Comments
 (0)