Skip to content

emphasize that executeCode return values are discarded - #299

Open
maxwellpeterson wants to merge 1 commit into
mainfrom
mpeterson/code-tool-console-log
Open

emphasize that executeCode return values are discarded#299
maxwellpeterson wants to merge 1 commit into
mainfrom
mpeterson/code-tool-console-log

Conversation

@maxwellpeterson

Copy link
Copy Markdown
Member

I often see the Workshop agent try to return values from executeCode calls, only to realize afterward that return values are discarded and it should use console.log() instead. We should emphasize this behavior in the executeCode tool description so the agent gets it right the first time.

Fixes #209

@github-actions github-actions Bot added the kernel Changes to the Workshop kernel label Aug 21, 2026
@github-actions

Copy link
Copy Markdown

Preview: pr299-mpeterson-cod-f17f3bbd

https://pr299-mpeterson-cod-f17f3bbd-router.cloudflare-os-previews.workers.dev

Dashboard · deleted when this PR closes

@maxwellpeterson
maxwellpeterson marked this pull request as ready for review August 21, 2026 18:21
@maxwellpeterson
maxwellpeterson force-pushed the mpeterson/code-tool-console-log branch from d00d0e6 to a710e39 Compare August 21, 2026 18:25
Comment thread packages/workshop-backend/src/agent.ts Outdated

The function also receives a \`self\` parameter which is a magic object that points back to this chat thread. Calling any method on \`self\`, like \`self.foo(123)\`, delivers a callback message to this chat and activates you to respond. \`self\` can be passed over RPC (e.g. to a subscription method) and stored in a Durable Object's KV storage for long-term callbacks. When an agent callback is received, it appears in your env under a name like \`PARAMS_1\`, with \`.args\` (the callback arguments), \`.resolve(value)\` (to return a value to the caller), and \`.reject(error)\` (to reject with an error).

The function's return value is discarded and will not appear in the tool result. Use console.log() for every value you need to inspect. Before the function returns, explicitly log the result of the operation when it will help confirm what happened.

@ndisidore ndisidore Aug 21, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly worth condensing to what I had originally

The exported function's return value is ignored; use \`console.log()\` to produce tool output.

either way would suggest wrapping in `console.log()` to be consistent with the rest of the block

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added backtick wrappers. I prefer the current prose and feel like it matches the rest of this block better

I often see the Workshop agent try to return values from executeCode
calls, only to realize afterward that return values are discarded and it
should use console.log() instead. We should emphasize this behavior in
the executeCode tool description so the agent gets it right the first
time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Changes to the Workshop kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

executeCode can drop module return values

2 participants