Read the instructions here. Discuss with me what you plan to do and discuss edge cases, what my intentions are with the plan, or details you need. We will work interactively on this REDACTED.md
Assistant
Let me read the instructions first.
Assistant
Now let me quickly look at the key files mentioned to understand the current state before we discuss.
Assistant
Excellent. I now have a thorough understanding of the landscape. Let me lay out what I see and then we can discuss the edge cases and design decisions.
What the instructions ask for
You want to introduce 6 new HARMONIA_* environment variables that control which LLM bdi-kit uses for its various matching methods:
Be passed into the container by exec_apptainer_harmonia.sh
Be logged/printed for observability
Actually be read and used by the code that calls bdi-kit
Key questions and edge cases
1. Where does the "wiring" happen?
bdi-kit itself doesn't read these env vars — it accepts model_name / reranker_model as constructor arguments. So something in Harmonia's code must read the HARMONIA_* env vars and pass them as arguments when calling bdi-kit's matching functions.
Question: Where does Harmonia currently call bdi-kit's schema/value matching? Is it in the BDIKitContext (the Beaker context), or does the LLM agent invoke bdi-kit tools that eventually call these? I need to find the exact call sites to wire things up. Do you already know, or should I trace through the code?
2. The two-phase schema matching note
You wrote: "for schema matching the two-phase approach can also call methods that use an LLM. Make sure that this works."
I interpret this as: Harmonia has a two-phase schema matching pipeline where phase 1 might use one method and phase 2 another. If either phase uses an LLM-backed method (llm, magneto_zs_llm, magneto_ft_llm), the corresponding HARMONIA_* var should control which LLM is used. Is that correct, or is there something more nuanced?
3. Hyphen in env var names
HARMONIA_LLM_FOR_MAGNETO_ZERO-SHOT_SCHEMA_MATCHING and HARMONIA_LLM_FOR_MAGNETO_FINE-TUNED_SCHEMA_MATCHING contain hyphens. Hyphens are technically valid in env var values but not standard in env var names — many shells and tools (including export, bash, docker --env) don't support hyphens in variable names. YAML keys are fine with hyphens, but once they become env vars it's problematic.
Suggestion: Rename to underscores: HARMONIA_LLM_FOR_MAGNETO_ZERO_SHOT_SCHEMA_MATCHING and HARMONIA_LLM_FOR_MAGNETO_FINE_TUNED_SCHEMA_MATCHING. Sound good?
4. bdi-kit is installed in the container at build time
The .def file installs bdi-kit from the local /jupyter source. The version in the container is 0.10.0.dev0. The LLM models are hardcoded as defaults (openai/gpt-4o-mini) in bdi-kit's constructors. We have two options:
Option A: Modify bdi-kit source to read env vars directly (simpler, but means patching bdi-kit)
Option B: Have Harmonia's code read the env vars and pass them as constructor kwargs when calling bdi-kit (cleaner separation, but requires knowing all call sites)
Which approach do you prefer? Or is there a third option — e.g., the MCP server's --llm flag already does something like this?
5. Config YAML structure
Where in the YAML config should these live? I see two natural options:
Fall back to bdi-kit's built-in default (openai/gpt-4o-mini)?
Fall back to the experiment's main LLM_SERVICE_MODEL?
Fail loudly?
My instinct is: fall back to bdi-kit's defaults (i.e., don't set the param and let bdi-kit use its own default), so existing experiments aren't broken. But using the experiment's main LLM could also make sense if you want "use the same LLM for everything" as the default behavior.
What are your thoughts on these? Once we align, I can trace the exact call sites and put together an implementation plan.
User
I am not sure. Investigate the code here: /hpc/compgen/projects/llm_GEO_project/harmonia_metadata_agent/analysis/dstoker/harmonia/src/bdikit_context
Correct.
do rename to underscores yes
The latest version of bdi-kit is 0.9. Before all else we need to update to the latest version. Could you check within a running container with the version is before we move on?
New top-level section. It is the LLM that Harmonia's AI agent internally uses, which is different from the LLM agent that is doing the top-level analysis/user interaction. However, the default should be equal to the top-level LLM.
fall-back to the experiment's main LLM_SERVICE_MODEL.
For 4 we may need to do a bit more research. Can you trace the changes in bdi-kit over the versions, and compare its source code to what is installed in the container? Specifically, I cloned version 0.9 here: /hpc/compgen/projects/llm_GEO_project/bdi-kit but you said that in the container something else is installed. HEre is the file that builds the .sif from the .def. Please use this: /hpc/compgen/projects/llm_GEO_project/harmonia_metadata_agent/analysis/dstoker/harmonia/build_harmonia_apptainer.sh and /hpc/compgen/projects/llm_GEO_project/harmonia_metadata_agent/analysis/dstoker/harmonia/harmonia_beaker_LLM_agent_environment_apptainer.def to determine completely how bdikit is installed in the container.
Note: I made changes to bdikit-context above the earlier implementation, so we will have to compare how i) bdi-kit context is implemented in the latest version of bdikit (0.9), since it incorporates the LLM agent that first was standalone Harmonia; ii) what changes we made in the local version; iii) use this to inform the plan for updating and properly making the LLMs used for values within Harmonia settable in config files.
Assistant
Good, let me investigate all of this systematically. Let me start with several parallel investigations.
Assistant
Now let me also check the actual pinned commit in the container's pyproject.toml and read the key procedure templates, since those are the critical "wiring" points.
Assistant
Now let me check the bdi-kit API at the pinned commit vs v0.9 to understand exactly what parameters match_schema and match_values accept in each version.
Assistant
This is very revealing. Let me also check the match_values signature at the pinned commit and in v0.9.
Assistant
Now I have the full picture. Let me also verify the bdi-kit version inside the running container as you asked.
Assistant
The container seems to need a compute node allocation to run. Let me check if we're on a submit node and try differently.
Assistant
Apptainer isn't available on the submit node. We can't directly inspect the running container from here. However, we can determine exactly what's installed by tracing the build process. Let me verify what commit 41f6c26 contains.
User
[Request interrupted by user]
User
You can execute a container by doing srun, and then executing this to run the container: /hpc/compgen/projects/llm_GEO_project/harmonia_metadata_agent/analysis/dstoker/harmonia/exec_apptainer_harmonia.sh
Do that, then continue.
Assistant
Let me get an interactive session and check the container.
Assistant
This is extremely revealing. Let me also check what the GPT matcher looks like in this old version.
Assistant
Now I have the complete picture. Here's my analysis:
Summary of findings
What's in the container right now
Package
Version
bdi-kit
0.5.0.dev0 (pinned to WIP commit 41f6c26)
bdikit-context
0.0.1
beaker-kernel
1.14.0
The gap is massive
The container's bdi-kit (0.5.0.dev0) vs the cloned v0.9 differ fundamentally:
Feature
Container (v0.5-dev)
v0.9
Schema matchers
gpt, coma, cupid, etc. (old names)
llm, magneto_ft_llm, magneto_zs_llm, etc. (new names)
We will implement the full plan so everything works as needed. Rebuilding is fine as part of the plan. Whatever can be executed in parallel while the container is rebuilding should do so.
Question 2:
Yes, check this. Internally it should call the appropriate LLM matchers, so if that goes well it should work. Still chec this.
Question 3: the LLM calls what it wants to call and it should work.
Question 4:
I guess pin to the v0.9 version for now.
Then an extra point from my side: I originally implemented any-llm integration as an easy way of integrating many different LLMs. I see that Harmonia has chosen liteLLM instead. Given this comparison document: /hpc/compgen/projects/llm_GEO_project/harmonia_metadata_agent/analysis/dstoker/harmonia/documentation/miscellaneous/anyllm_vs_litellm_comparison.docx and the current state of the codebase, would it make sense or be easy to switch to litellm instead?
Assistant
Let me read that comparison document and check the two_phase matcher, then we can finalize the plan.
Assistant
The .docx is binary. Let me convert it and retry the other searches.
Assistant
Let me try another approach for the docx file.
Assistant
Now I have everything. Let me synthesize all findings into a coherent discussion.
Complete picture — ready for discussion
The litellm question
Having read the comparison doc and traced the code, here's the key insight:
There are two separate LLM integration points in Harmonia, and they use different libraries:
Integration Point
Currently Uses
Purpose
Top-level agent (Beaker/Archytas)
any-llm-sdk via AnyLLMModel/ChatAnyLLM
The AI agent that reasons, calls tools, talks to user
bdi-kit internal (schema/value matching)
litellm (inside bdi-kit v0.9)
LLM calls within method="llm", magneto_*_llm, etc.
So right now you have two different LLM abstraction layers in the same system. After upgrading bdi-kit to v0.9, both would be active simultaneously.
Should you switch the top-level agent to litellm too? Here's my analysis:
Arguments FOR switching to litellm:
Unified stack — one LLM library instead of two, simpler debugging and dependency management
bdi-kit already requires litellm — it's a dependency anyway, so you're not adding anything new
litellm has better token counting — the current any-llm adapter uses a rough 4-chars-per-token estimate (get_num_tokens_from_messages), litellm has model-specific counters
The integration surface is small — any-llm is only used in 2 files (anyllm.py and direct.py), ~700 lines total
Model name format is identical — both use provider/model format (e.g., openai/gpt-4o-mini)
You'd remove a dependency — any-llm-sdk could be dropped from pyproject.toml and the container
Arguments AGAINST:
More scope in this task — it's extra work on top of the bdi-kit upgrade
any-llm wraps official SDKs — higher fidelity to provider behavior (per the comparison doc)
Working system — the current any-llm integration works and has been tested
User
[Image: image/png]
User
Here is the document text:
Assistant
Thanks for sharing the rendered version. I already extracted the full text from the docx (the last bash command got it all), so I have the complete comparison.
To summarize where we are — do you have any thoughts on the questions I posed at the end?
two_phase default behavior: let it use its non-LLM defaults unless the agent explicitly requests LLM-based sub-matchers? Or should we inject the HARMONIA_LLM_* models into two_phase's sub-matchers automatically?
litellm switch: do it as a separate Phase 4, or fold it into the same task?
The overall plan — does the 3-phase (+ optional phase 4) structure work for you?
Once you confirm or adjust, I'll formalize into an implementation plan we can execute.
User
Your two-phase matcher approach seems valid. I agree with making the switch to liteLLM only a separate plan.
So now I want you to:
write the full plan for the update of bdikit and configuration of what LLMs bdi-kit uses, with details of what we discussed and context that is needed for a fresh Claude instance getting to work on this problem (i.e. very clear step-by-step instructions and files to change) to REDACTED.md
write the full and detailed plan, including necessary context and all relevant files, for the switch to the liteLLM backend in REDACTED.md
Report to me with any concerns after this is done.
Assistant
Let me first check the plans directory exists and read a few more files I need for complete context in the plans.
Assistant
Now let me also read the remaining critical files I need for complete plan context.
Assistant
Now let me also quickly read one sample experiment config and the exec script's env-passing section to have precise line references.
Assistant
Now I have everything I need. Let me also read the exec script's logging/printing section to see exactly where env vars are printed.
Assistant
Good. Now I have all the context I need to write both plans. Let me write them now.
Assistant
Both plans are written. Here's a summary:
Plan 1: bdi-kit upgrade + LLM selection
9 steps covering:
Pin bdi-kit to v0.9.0 in pyproject.toml
Fix breaking API changes (column_mapping → attribute_matches, method names)
Add _get_method_args_for_schema() / _get_method_args_for_values() helpers in agent.py that read the 6 HARMONIA_* env vars
Update Jinja2 procedure templates to pass method_args to bdi-kit
Wire generate_env.py to emit the new vars from a bdikit_models: YAML section
Update provider maps in __init__.py and generate_env.py
Remove any-llm-sdk from dependencies
Update container .def and build script
Backwards compatibility: anyllm:* prefix still maps to new litellm classes
Includes litellm provider model string reference table
One concern
I noticed the .sif file was built on Feb 5. The --mem=32G in the build script template might not be enough if bdi-kit v0.9 pulls in heavier dependencies (magneto-python, torch, flair, etc.). You already changed the plan to --mem=40G — that's wise. We should also watch disk space during the build since the storage is at 97% capacity (3.4TB free). The build uses $TMPDIR scratch space which is separate, but the final .sif (~5GB) writes to the project directory.
User
can plan 2 be executed in parallel or do we need to wait for the new container to be built etc.?
Assistant
Plan 2 (liteLLM switch) can be almost entirely done in parallel with Plan 1. Here's the breakdown:
Can run in parallel with Plan 1 (code changes):
Writing the new litellm_model.py and litellm_direct.py files
Updating the provider maps in __init__.py and generate_env.py
Updating pyproject.toml (remove any-llm-sdk)
Updating the .def file and build_harmonia_apptainer.sh
The one constraint: Both plans require a container rebuild, and you only want to rebuild once. So the ideal execution order is:
Do all code changes from both plans first
Rebuild the container once with everything
Verify everything together
There's no dependency between the two plans at the code level — the liteLLM switch touches llm/anyllm.py, llm/direct.py, and llm/__init__.py, while the bdi-kit upgrade touches agent.py, procedures/, generate_env.py, and exec_apptainer_harmonia.sh. The only shared file is pyproject.toml (both plans edit it) and generate_env.py (both update provider paths), which is trivial to merge.
So yes — do both plans' code changes in parallel, then one container rebuild at the end. Want me to update both plans to reflect this merged execution strategy?
User
I want you to write me a message that I can paste into a Claude instance that is working on plan 1, that tells it to execute plan 2's code changes after plan 1's code changes are done, then rebuild the container once.
Assistant
Here's the message you can paste:
After you finish implementing Plan 1 (bdi-kit upgrade + LLM selection), there is a second plan to execute before rebuilding the container. Both plans share one container rebuild at the end.
Plan 2 location:REDACTED.md
Read that plan in full and execute all its code changes (Steps 1-9). The key summary:
Goal: Replace any-llm-sdk with litellm as the top-level Beaker/Archytas agent LLM backend. any-llm is only used in 2 files (src/bdikit_context/llm/anyllm.py and src/bdikit_context/llm/direct.py), so the scope is contained.
What to do:
Create src/bdikit_context/llm/litellm_model.py — new file containing ChatLiteLLM (replaces ChatAnyLLM) and LiteLLMModel (replaces AnyLLMModel). These must implement the same Archytas BaseArchytasModel interface. Use litellm.acompletion() instead of AnyLLM.create(). Use litellm.token_counter() for token counting. Handle the litellm model string format (provider/model, with special cases like ollama_chat/ for Ollama). See plan Section 5.1 for full details.
Create src/bdikit_context/llm/litellm_direct.py — replaces direct.py. Same DirectLLMRunner interface but using litellm.acompletion() instead of AnyLLM.create().
Update src/bdikit_context/llm/__init__.py — change all provider import paths from bdikit_context.llm.anyllm.AnyLLMModel to bdikit_context.llm.litellm_model.LiteLLMModel. Handle both litellm: prefix (new) and anyllm: prefix (backwards compatibility). Update configure_llm_environment() accordingly.
Update pyproject.toml — remove any-llm-sdk from dependencies (litellm is already added by Plan 1). Remove all anyllm-* optional dependency groups.
Update harmonia_beaker_LLM_agent_environment_apptainer.def — remove the any-llm-sdk installation section (lines 89-98) and its verification. Replace with litellm verification. Update the installed packages check.
Update build_harmonia_apptainer.sh — replace any-llm verification steps in Phase 5 and Phase 7 with litellm/LiteLLMModel verification.
User
I think the update to bdikit, which now has different methods etc. necessitates updating the tool prompts that Archytas sees.
Specifically, could you analyze:
how bdikit now organizes tools in the updated version (can check here /hpc/compgen/projects/llm_GEO_project/bdi-kit or read the plan for updating to check this)
then discuss with me what changes need to be made. While you are at it, please also make sure to make a plan to make prompt folders in /hpc/compgen/projects/llm_GEO_project/harmonia_metadata_agent/analysis/dstoker/harmonia/src/code_context and /hpc/compgen/projects/llm_GEO_project/harmonia_metadata_agent/analysis/dstoker/harmonia/src/codeact_context (now their prompts are just in the file if I don't set anything, I want specific, versioned prompts to point the environment variable towards when running experiments.)
So:
check tool descriptions/prompts versus updated bdikit-version
check how to make prompts folders for the two other agent contexts
Report your findings and discuss with me until we can get an implementation plan for changes to make
Assistant
Let me investigate all of this in parallel.
Assistant
Excellent. Now I have the complete picture. Let me also quickly check a couple of specific details about the procedure templates vs v0.9 API.
Assistant
Now let me check the v0.9 API for the exact function names to identify mismatches.
User
Continue from where you left off.
Assistant· <synthetic>
No response requested.
User
hello.
Assistant
Hello! I see you've been making progress on the plans — several files have been updated (pyproject.toml pinned to bdi-kit 0.9.0, procedure templates updated, generate_env.py updated, prompt_logging.py updated, etc.).
Where would you like to pick up? When we left off, I was investigating:
bdi-kit v0.9 tool descriptions vs current Harmonia prompts — comparing what's in src/bdikit_context/prompts/ against the updated bdi-kit API
Creating versioned prompt folders for code_context and codeact_context — so you can point env vars at specific prompt versions for experiments
I had the bdi-kit v0.9 API exploration results ready. Want me to continue with that analysis, or has the scope changed given the new plan file you have open (25_02_2026_2238_fix_context_issues.md)?
Assistant
Now I have the critical comparison. Let me check one more thing — how top_matches was renamed.
Assistant
Now let me also check the preview_domain parameter name change.
User
I want you to continue with that, yes. Report back to me.
Assistant
Let me continue the analysis. I already have the bdi-kit v0.9 API findings from earlier. Now let me read the current prompts and the code_context/codeact_context sources.
Assistant
Now I have everything. Let me present the findings.
Analysis: What Needs Updating
A. Procedure Templates vs v0.9 API — Breaking Changes
Two procedure templates are broken and not yet covered by Plan 1:
top_matches.py — bdi.top_matches() no longer exists, it's now bdi.rank_schema_matches(), and columns is now attributes
get_gdc_acceptable_values.py — column parameter renamed to attribute
B. Tool Prompt Descriptions vs v0.9 — What's Outdated
1. match_schema.j2 — Needs updating:
Should mention method_args parameter
Should list the new method names: magneto_ft_bp (default), magneto_zs_bp, , , , plus the legacy ones
Assistant
Now I have all three investigations complete. Let me also quickly check what the bdi-kit v0.9 API function top_matches is called now, since I recall the API changed.
Assistant
Now let me also check the top_matches procedure template to see exactly what it calls.
User
Could you repeat what you just said? it seems to not be properly saving.
User
[Request interrupted by user]
Assistant
This confirms a critical breaking change. Now I have the complete picture. Here's my analysis:
Analysis: Tool Prompts vs bdi-kit v0.9
Breaking changes in the bdi-kit API
Harmonia tool
Current call
v0.9 API
Status
match_schema
bdi.match_schema(...)
bdi.match_schema(...)
OK (signature changed but procedure template already updated)
Says column_mapping but v0.9 param is attribute_matches
Doesn't mention available methods:
User
For 1. make it rank_schema_matches what the agent sees as well. Better to have no old-style stuff anywhere.
I want top keep the v1 v2 for now. I want you to indeed make all changes needed to get this to work, including bdikit main.j2, generate_env.py and the experiment configs where needed. Now write a full plan called DATETIME_update_tool_prompts_new_version_bdikit_and_add_prompt_files_codecontextagent_and_codeactagent.md in /hpc/compgen/projects/llm_GEO_project/harmonia_metadata_agent/analysis/dstoker/harmonia/documentation/plans. Make it comprhensiove: a fresh Claude instance should have all the information needed to implement the fixes in all files needed.
Respond to me when the plan is done.
Assistant
Let me gather the remaining details I need for a fully self-contained plan.
Assistant
Now let me read the context.py to understand exactly how tool descriptions are loaded/overridden, and the code/codeact context files.
Assistant
Now let me read the prompts __init__.py and the codeact agent.py for the summary template default.
Assistant
Now let me check the full list of existing experiment configs to know what needs updating.
Assistant
Now let me check the current bdikit prompts directory structure.
Assistant
Now let me read the current tool prompt templates to include their exact content in the plan.
Assistant
Good, now let me check how rank_schema_matches works in v0.9 with the attributes parameter.
Assistant
Now I have everything needed. Let me write the comprehensive plan.
Assistant
The plan is written at 26_02_2026_1143_update_tool_prompts_new_version_bdikit_and_add_prompt_files_codecontextagent_and_codeactagent.md.
Update code_context/context.py — load from v1 file by default, env var override
Update codeact_context/context.py — load from v1 files by default, env var overrides
Optionally update experiment YAML configs to explicitly reference prompt versions
One thing to flag: in the get_gdc_acceptable_values tool, I kept the agent-facing parameter name as column (what the LLM sees and uses) but changed the template variable to attribute (what the bdi-kit API expects). This avoids confusing the LLM while fixing the API compatibility. If you'd prefer to rename the agent-facing param too, let me know.
User
Why keep this split, rather than showing the LLM the correct internals? if it decides to look at help or documentation it will get confusing error messages, right?
Assistant
You're right. If the LLM calls help(bdi.preview_domain) or reads an error traceback, it'll see attribute as the parameter name and get confused if the tool says column. Better to be consistent end-to-end.
Let me update the plan to rename the agent-facing parameter from column to attribute as well — in the tool's Python signature in agent.py, its docstring, and the .j2 tool prompt.
Assistant
Now update the tool prompt section for get_gdc_acceptable_values.j2 to match.
Assistant
Now remove the caveat at the bottom of the plan that mentioned keeping the split.
Assistant
Done. The plan now uses attribute consistently end-to-end — in the Python tool signature, the docstring, the Jinja2 template variable, the procedure template, and the tool description. No split between what the LLM sees and what bdi-kit expects.
The method names in agent.py are wrong for the container. Your VALID_SCHEMA_METHODS list includes magneto_zs_llm, magneto_ft_llm, llm — but the container only has gpt, coma, cupid, etc. The agent is advertising methods that don't exist in the installed bdi-kit.
Updating bdi-kit from 0.5-dev to 0.9 is a prerequisite before the HARMONIA_LLM_* env vars make sense. In v0.5-dev, the gpt matcher is hardcoded to OpenAI. In v0.9, the llm matcher uses litellm and accepts model_name as a constructor kwarg via method_args.
The Jinja2 procedure templates currently don't pass method_args — they only pass method. After upgrading to v0.9, we'd need to also pass method_args={"model_name": ...} in the rendered code.
Parameter name changed: v0.9 renamed column_mapping to attribute_matches in match_values. The procedure template uses column_mapping which would break.
What I think the plan should be (for discussion)
Phase 1: Upgrade bdi-kit in the container to v0.9
Update pyproject.toml to pin bdi-kit==0.9.0 (or the v0.9.0 tag)
Fix the breaking API changes:
column_mapping → attribute_matches in match_values procedure template
Update VALID_SCHEMA_METHODS and VALID_VALUE_METHODS in agent.py
Rebuild the container
Phase 2: Wire the HARMONIA_LLM_* env vars
Add 6 new env vars (with underscores, not hyphens) to config YAML under a new bdikit_models: section
Default all to LLM_SERVICE_MODEL (the experiment's top-level LLM)
Update generate_env.py to read and emit these
Update exec_apptainer_harmonia.sh to pass and log them
Update the Jinja2 procedure templates to pass method_args with the right model name based on the method being used
The agent code in agent.py reads the env vars and injects them into the get_code() call
Open questions for you
Rebuild timing: Rebuilding the container takes a while (the build script allocates 2h/32GB). Are you OK with this being part of the plan, or do you want to do the code changes first and rebuild separately?
The two_phase schema matcher in v0.9 — this can internally use LLM-based sub-methods. Should we also pass model names through for that? I'd need to check how two_phase is parameterized in v0.9.
Do the current experiments actually use the LLM-based matchers? Since the defaults are coma/tfidf (non-LLM), and the agent picks methods based on the AI's reasoning, does the agent currently ever try to call gpt/llm methods in practice? This affects urgency — if the LLM-based matchers are never used right now, the upgrade is more about enabling new capability.
Should we pin to v0.9.0 tag exactly, or to the devel branch HEAD (which is 0.10.0.dev0, a few commits past v0.9)?
My recommendation: It makes sense to switch, but I'd suggest doing it as a separate phase after the bdi-kit upgrade, since it's cleanly isolated. The bdi-kit upgrade + HARMONIA_LLM_* wiring is the critical path. The litellm switch is a nice-to-have that simplifies the stack. We could plan for it but execute it second.
The two_phase matcher
Good news: In v0.9, TwoPhase accepts top_k_matcher and schema_matcher as constructor kwargs, and the factory passes **method_args through to the constructor. So you can do:
However, two_phase does not automatically inherit the HARMONIA_LLM_* env vars — sub-matchers need to be explicitly instantiated with the model name. This means if the agent calls method="two_phase", we need to decide:
Do we pre-construct the sub-matchers with the configured LLM model names from env vars?
Or do we let two_phase use its defaults (MagnetoFTBP + SimFlood, both non-LLM)?
I think the cleanest approach is: if the agent calls two_phase, we let bdi-kit use its defaults (non-LLM sub-matchers). The HARMONIA_LLM_* vars only apply when the agent explicitly requests an LLM-based method. This keeps things simple and predictable. Thoughts?
Breaking API changes in the upgrade
The rename column_mapping → attribute_matches in v0.9's match_values is a breaking change. The procedure template and agent code both need updating. This is straightforward but needs to be done carefully.
Summary of proposed plan
Phase 1: Upgrade bdi-kit to v0.9
Update pyproject.toml to pin bdi-kit @ git+...@v0.9.0
Update procedure templates: column_mapping → attribute_matches, add method_args support
Update match_values.py template to pass method_args
Update match_schema.py template to pass method_args
Phase 2: Wire HARMONIA_LLM_ env vars*
Add bdikit_models: section to YAML config schema
Update generate_env.py to emit the 6 new vars
Update exec_apptainer_harmonia.sh to pass and log them
Update agent.py to read env vars and inject method_args into procedure calls
Update procedure templates to accept and pass method_args
Default all to LLM_SERVICE_MODEL
Phase 3: Rebuild container
Rebuild with updated dependencies
Verify bdi-kit v0.9 is installed
Verify all methods work
Phase 4 (optional, separate): Switch agent LLM backend from any-llm to litellm
What are your thoughts? Anything you want to adjust before I formalize this into an implementation plan?
Update generate_env.py — in get_provider_import_path(), change anyllm:* paths to point to bdikit_context.llm.litellm_model.LiteLLMModel. Add litellm:* entries too.
Delete src/bdikit_context/llm/anyllm.py and src/bdikit_context/llm/direct.py (git history preserves them).
Important context:
Read the existing anyllm.py and direct.py files carefully — the new litellm equivalents must satisfy the exact same interfaces (Archytas BaseArchytasModel, LangChain AIMessage with tool_calls, etc.)
The _convert_messages() and bind_tools() methods are nearly identical since both any-llm and litellm use OpenAI-compatible formats
litellm is stateless (litellm.acompletion(...)) — no client object to create, unlike AnyLLM.create()
For Ollama, use ollama_chat/model as the litellm model string (not ollama/model)
Keep anyllm:* entries in provider maps for backwards compatibility with existing YAML configs
After both plans' code changes are done: rebuild the container ONCE using:
bash
srun -J apptainer_build_claude-code --time=02:00:00 --mem=40G --gres=tmpspace:100G bash
cd /hpc/compgen/projects/llm_GEO_project/harmonia_metadata_agent/analysis/dstoker/harmonia
./build_harmonia_apptainer.sh
Then verify both bdi-kit v0.9 and litellm integration work inside the new container.
magneto_ft_llm
magneto_zs_llm
llm
Currently says nothing about available methods
2. top_matches.j2 — Needs renaming and rewriting:
Tool name should change to rank_schema_matches (or keep top_matches as the agent-facing name but describe the new function)
Should mention top_k parameter (now explicit, default 10)
Should mention attributes not columns
Should mention method and method_args (the top-k function also accepts these)
3. match_values.j2 — Needs updating:
Should mention method_args parameter
Should list available methods: tfidf (default), embedding, llm, llm_numeric, edit_distance
Should mention attribute_matches not column_mapping (even though the agent-facing parameter name can stay the same)
Currently says "top 10 value matches" — this is misleading, match_values returns best matches, not top-k
4. materialize_mapping.j2 — Mostly fine, minor update:
The mapping_spec format description is still accurate
5. get_gdc_acceptable_values.j2 — Needs updating:
Should reference attribute not column internally
C. Prompts Folders for Code Context and CodeAct Context
Currently:
BDIKit Context: Has a proper prompts/ directory with Jinja2 templates, PromptLoader class, and env var overrides — the gold standard
Code Context: System prompt is an inline string in context.py. Only override is a single env var (HARMONIA_CODE_CONTEXT_PROMPT) pointing to a file that replaces the whole thing
CodeAct Context: System prompt is an inline string in context.py. Overrides via HARMONIA_CODEACT_PROMPT and HARMONIA_CODEACT_SUMMARY_TEMPLATE env vars
You want versioned prompt folders for Code Context and CodeAct Context, similar to BDIKit's structure, so experiments can point HARMONIA_CODE_CONTEXT_PROMPT or HARMONIA_CODEACT_PROMPT at specific prompt versions.
Discussion Points
1. Tool name: top_matches → rank_schema_matches
In v0.9, top_matches() is gone and replaced by rank_schema_matches(). Two options:
Option A: Rename the Archytas tool to rank_schema_matches — cleaner, matches v0.9 API exactly. But this changes what the agent sees and may affect prompts/behaviors.
Option B: Keep the tool name top_matches in the agent, but have the procedure template call bdi.rank_schema_matches() internally. The agent doesn't need to know the internal function name changed.
I'd suggest Option B — it's less disruptive and the tool name top_matches is more intuitive for the LLM agent than rank_schema_matches. Thoughts?
2. Should we add new tools for v0.9 capabilities?
v0.9 introduces functions that don't have tools yet:
rank_value_matches() — top-k value matches (currently the agent can only get best match via match_values)
evaluate_schema_matches() — LLM-based quality evaluation of schema matches
evaluate_value_matches() — LLM-based quality evaluation of value matches
Do you want to expose these as agent tools? They'd let the agent ask "are these matches good?" using an LLM evaluator, or get top-k value alternatives. Or is that scope creep for now?
3. Prompt versioning for Code/CodeAct contexts
For the prompt folders, I propose this structure:
code
src/code_context/prompts/
v1/
system.txt # The current inline prompt, extracted
v2/ # Future versions...
system.txt
src/codeact_context/prompts/
v1/
system.txt # The current inline prompt, extracted
summary_template.txt # The current DEFAULT_SUMMARY_TEMPLATE, extracted
v2/
system.txt
summary_template.txt
Question: Should we use version folders (v1/, v2/) or date-based folders (25_02_2026/)? Date-based matches your conventions elsewhere.
4. Should BDIKit's system prompt (main.j2) also be updated?
The system prompt in main.j2 describes the harmonization workflow with specific references to tool names and behavior. Given the v0.9 API changes, some parts are inaccurate:
It mentions match_schema, top_matches, match_values, materialize_mapping, get_gdc_acceptable_values — the tool names stay the same (we're wrapping), so this is OK
The method descriptions are generic enough to still work
But it doesn't mention the new matching methods (LLM-based, magneto, etc.)
Do you want to update the system prompt content, or just ensure the tool descriptions (the .j2 files) are accurate? The system prompt is more about workflow guidance, while tool descriptions are about API accuracy.
5. What about generate_env.py for code/codeact prompts?
Currently generate_env.py handles HARMONIA_CODE_CONTEXT_PROMPT and HARMONIA_CODEACT_PROMPT from the prompts: config section. But it doesn't handle HARMONIA_CODEACT_SUMMARY_TEMPLATE. Should we add that too?
What are your thoughts on these questions? Once we align, I'll write the implementation plan.
edit_distance, llm, llm_numeric, tfidf, embedding
Doesn't mention method_args parameter
3. tools/top_matches.j2 — Completely obsolete:
References bdi.top_matches() which doesn't exist in v0.9
v0.9 equivalent is bdi.rank_schema_matches() with different parameters (attributes not columns, has top_k param)
4. tools/get_gdc_acceptable_values.j2 — Minor:
Says column but v0.9 renamed the param to attribute
Content is still correct conceptually
5. tools/materialize_mapping.j2 — Largely OK:
The mapping spec format description is still valid
v0.9 added merge_mappings() as a helper which could be mentioned
6. system/main.j2 — Several issues:
References top_matches tool which needs renaming
The 3-step workflow description is still valid but could mention new evaluation functions
Doesn't mention the new LLM-based methods available for both schema and value matching
New v0.9 API functions with no Harmonia tool equivalent
v0.9 function
What it does
Add as tool?
rank_schema_matches()
Top-k schema matches (replaces top_matches)
Yes — must replace top_matches
rank_value_matches()
Top-k value matches
Maybe — useful for finding alternative value mappings
evaluate_schema_matches()
LLM-based schema match evaluation
Maybe — could help agent verify its work
evaluate_value_matches()
LLM-based value match evaluation
Maybe — same
merge_mappings()
Helper to combine mappings
Maybe — simplifies materialize step
view_value_matches()
Display grouped value matches
No — Jupyter display, not agent-relevant
Analysis: code_context and codeact_context prompt extraction
For experiment reproducibility, you want versioned prompt folders you can point to via env vars. The mechanism already exists for code_context (HARMONIA_CODE_CONTEXT_PROMPT) and codeact_context (HARMONIA_CODEACT_PROMPT + HARMONIA_CODEACT_SUMMARY_TEMPLATE). What's missing is the actual prompt files — the defaults are only in Python source code.
So for each context, we'd create a versioned prompts directory:
1. Rename top_matches tool to rank_schema_matches?
The top_matches tool wraps bdi.top_matches() which no longer exists. We need to either:
Option A: Rename the tool to rank_schema_matches and update everything
Option B: Keep the tool name top_matches in agent.py but call bdi.rank_schema_matches() internally
Option A is cleaner but changes the tool name the LLM sees. Option B preserves backwards compatibility in prompts/configs. What's your preference?
2. Add new tools from v0.9?
rank_value_matches, evaluate_schema_matches, evaluate_value_matches, and merge_mappings are new in v0.9. Should we:
Add them all as agent tools now?
Just add rank_value_matches (symmetric with rank_schema_matches)?
Leave them for later?
3. How much method detail in tool prompts?
Should the tool prompts list all available methods with descriptions? For example:
code
Available schema matching methods:
- magneto_ft_bp (default): Fine-tuned Magneto with bipartite reranker
- llm: Pure LLM-based matching (uses configured LLM)
- magneto_ft_llm: Fine-tuned Magneto with LLM reranker
...
This helps the LLM make informed method choices. But it also adds prompt length. Your call on how detailed.
4. Versioned prompt folder structure
Do you want:
Option A: Prompts live under experiments/experiment_1.../prompts/v1_date/ (per-experiment)
Option B: Prompts live under src/bdikit_context/prompts/ as defaults, with versioned overrides under experiments
Option B means the defaults are always in source, and experiment configs can optionally point to override folders. This is how it already works for bdikit_context.
5. The get_gdc_acceptable_values procedure — column vs attribute
The procedure calls bdi.preview_domain("gdc", column="{{ column }}") but v0.9 renamed the param to attribute. This needs fixing in the procedure template. Should I add this to the plan?