Skip to content

fix(extraction): plumb custom_extraction_instructions into entity summary prompts#1578

Open
maxziro wants to merge 1 commit into
getzep:mainfrom
maxziro:feat/custom-instructions-entity-summaries
Open

fix(extraction): plumb custom_extraction_instructions into entity summary prompts#1578
maxziro wants to merge 1 commit into
getzep:mainfrom
maxziro:feat/custom-instructions-entity-summaries

Conversation

@maxziro

@maxziro maxziro commented Jun 12, 2026

Copy link
Copy Markdown

Problem

custom_extraction_instructions is honored by the node and edge extraction prompts, but it never reaches the entity summary stage: extract_attributes_from_nodes and its summary helpers have no way to receive it, so the extract_summaries_batch / extract_entity_summaries_from_episodes prompts always run unconstrained.

Practical effect (how we hit this): with instructions like "Perform all extraction in Italian", entity names and edge facts come back in Italian as expected, while freshly composed entity summaries come back in English — even when the source episode is entirely Italian. Summaries that are produced by the fact-appending shortcut look fine (the facts are already constrained), which makes the gap surface only intermittently, on summaries the LLM actually composes.

Change

Thread the existing parameter through the summary path, mirroring how the extraction prompts already handle it:

  • extract_attributes_from_nodes(..., custom_extraction_instructions=None)_extract_entity_summaries_batch_process_summary_flight → prompt context ('' when unset).
  • Interpolate {context['custom_extraction_instructions']} in both summary prompt templates (extract_summaries_batch and extract_entity_summaries_from_episodes), same bare-line pattern as extract_message / extract_json / extract_text.
  • Pass the parameter at both call sites: add_episode and the bulk path (_resolve_nodes_and_edges_bulk, called by add_episode_bulk).
  • Docstrings updated accordingly.

No behavior change when the parameter is unset (empty string interpolation, like the other prompts). The Go-mirrored system prompt (_entity_episode_summary_system_prompt) is intentionally untouched — the injection lands in the user message.

Tests

Three unit tests in tests/utils/maintenance/test_node_operations.py, mirroring the existing custom-instructions plumbing tests in test_bulk_utils.py:

  • batch summary prompt receives the instructions (long-summary LLM route),
  • episode-prompt path (skip_fact_appending=True) receives them too,
  • extract_attributes_from_nodes passes them through to the batch helper.

tests/utils/maintenance/test_node_operations.py: 36 passed (33 existing + 3 new).

🤖 Generated with Claude Code

…mary prompts

custom_extraction_instructions reaches the node and edge extraction
prompts but not the entity summary stage: extract_attributes_from_nodes
and its summary batch helpers had no way to receive it, so the
extract_summaries_batch / extract_entity_summaries_from_episodes prompts
ran unconstrained. With instructions like 'write in Italian', names and
facts honored the directive while freshly composed summaries came back
in English.

Thread the parameter through extract_attributes_from_nodes ->
_extract_entity_summaries_batch -> _process_summary_flight into both
summary prompt templates (empty string when unset, matching the other
extraction prompts), and pass it at both call sites (add_episode and the
bulk path via _resolve_nodes_and_edges_bulk).

Co-Authored-By: Claude Fable 5 <[email protected]>
@zep-cla-assistant

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. For privacy information, see our Privacy Notice. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: [email protected]

or

I have read the CLA Document and I hereby sign the CLA behalf of my company, e-mail: [email protected]

Signature is valid for 6 months.


This bot will be retriggered when the Contributor License Agreement comment has been provided. Posted by the CLA Assistant Lite bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant