fix(extraction): use extra_body for response_format, fix content parsing#10
Open
qiaoranlaodou-cpu wants to merge 1 commit into
Open
Conversation
call_llm() has no top-level response_format kwarg, only extra_body -- passing it directly raised a TypeError that the except-clause silently swallowed, so automatic extraction never actually ran (looked like "filtering everything out" but was really a crash on every call). Even with that fixed, the old getattr(response, "content", response) couldn't read the result either: call_llm() returns the raw .choices[0].message.content response object, not something with a top-level .content attribute. Use extract_content_or_reasoning(), the same helper every other Hermes auxiliary caller uses. Added tests/test_extraction.py since there was no test coverage for this module at all.
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.
Bug
extraction.extract()callscall_llm(..., response_format={"type": "json_object"}).call_llm()has no top-levelresponse_formatkwarg, onlyextra_body— passing it directly raisesTypeError, which the surroundingexcept Exceptionsilently swallows. Net effect: automatic extraction never runs at all, but there's no visible error — it just looks like every conversation is being filtered out as "trivial".Even after fixing that, the response is parsed wrong:
text = getattr(response, "content", response)assumes the response has a top-level.contentattribute, butcall_llm()returns the raw.choices[0].message.contentobject (same shape used everywhere else in Hermes — seeoneshot.py). Thegetattrfalls through to its default (responseitself), gets stringified, and failsjson.loads, again silently caught.Fix
response_formatthroughextra_bodyinstead of as a top-level kwarg.agent.auxiliary_client.extract_content_or_reasoning(), the same helper other auxiliary callers use (also handles reasoning-modelcontent=Nonefallback).Testing
tests/test_extraction.py(there was no coverage for this module before) — mocksagent.auxiliary_clientper the repo's offline-test convention.extract()function with a mixed noisy/durable conversation — confirmed extraction now actually executes and returns valid JSON facts (previously: silent no-op).ruff checkandpytestboth pass on the changed files. Note:tests/test_memory_loop.py,tests/test_embeddings.py::test_client_uses_configured_base_url_and_key, andtests/test_longmemeval_benchmark.pyhave 12 pre-existing failures in my environment unrelated to this change (confirmed viagit stash— they fail identically onmain), looks like a locallancedbpackage version mismatch, not something this PR touches.