Read evaluate_js results with session.evaluate_js() - #3
Merged
Conversation
The template carried three helpers - json_from_execution_result, coerce_json_dict and parse_json_object, ~60 lines - whose only job was to dig JSON out of an ExecutionResult whose shape the caller could not rely on: try .data, then .data.structured, then .data.markdown, then .message, then eight more candidate keys, then a brace-matching fallback parser. session.evaluate_js(code) returns the evaluated value as a string (objects as JSON), so the read is json.loads(...) and all three helpers are dead. A failing script now raises with the actual JavaScript error instead of surfacing as "Could not parse evaluate_js result". Verified against staging: --result-index 2 runs end to end and downloads the PDF. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
arxiv-paper-finder(Python) carried three helpers —json_from_execution_result,coerce_json_dict,parse_json_object, ~60 lines — whose only job was to dig JSON out of anExecutionResultwhose shape the caller couldn't rely on: try.data, then.data.structured, then.data.markdown, then.message, then eight more candidate keys, then a brace-matching fallback parser.session.evaluate_js(code)(nottelabs/notte#909) returns the evaluated value as astr— objects as JSON — so the read is just:All three helpers are deleted (+8 / −69), along with a now-unused
reimport. A failing script also reports better: it raises with the actual JavaScript error instead of surfacing as"Could not parse evaluate_js result: <envelope repr>".Verification
Run against staging with a released-equivalent SDK:
--result-index 2completes end to end — bothevaluate_jscall sites (recent-list read, article open) succeed and the PDF downloads.Not touched
ts/downloads-files/arxiv-paper-finder) keepssession.execute({type: "evaluate_js"})—evaluate_js()is a Python SDK addition; the JS SDK has no equivalent yet.evaluate_jsto …", which describes the capability and stays accurate.Gate
Needs the
notte-sdkrelease containing nottelabs/notte#909 — merge once that's on PyPI, since templates run against the released SDK.🤖 Generated with Claude Code