Skip to content

feat: new agent template for tag and metadata filtering - #33

Open
MesekerWK wants to merge 11 commits into
mainfrom
mework/add-metadata-tag-filtering-agent-example
Open

MesekerWK wants to merge 11 commits into
mainfrom
mework/add-metadata-tag-filtering-agent-example

Conversation

@MesekerWK

Copy link
Copy Markdown
Contributor

Added a reusable RAM agent template that accepts JSON filters for source tags and custom metadata, including combined filters.

Signed-off-by: MesekerWK <meseker.fisseha@gmail.com>
Signed-off-by: MesekerWK <meseker.fisseha@gmail.com>
Signed-off-by: MesekerWK <meseker.fisseha@gmail.com>

@joshanderson-sas joshanderson-sas left a comment

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.

This looks good. One request though. Let's remove the "Tag filtering" part and just leave it at metadata filtering.

It's a bit confusing that we are combining two different features into a single example and the tags part doesn't really make sense (there's only one file).

We should make a separate example for "tags" and in that one there could be multiple files that get separate tags. We should also add custom source example code for applying a tag (if that doesn't already exist here)

MesekerWK and others added 8 commits November 9, 2026 10:52
Signed-off-by: joshanderson-sas <josh.anderson@sas.com>
Signed-off-by: joshanderson-sas <josh.anderson@sas.com>
Signed-off-by: joshanderson-sas <josh.anderson@sas.com>
Signed-off-by: joshanderson-sas <josh.anderson@sas.com>
Signed-off-by: joshanderson-sas <josh.anderson@sas.com>
response = ram_client.post_query(
prompt=question,
search_kwargs=search_kwargs,
persistent=False,

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.

Why is persistent false here?

Comment on lines +9 to +22
The entry point in [run.py](./run.py) writes three text files under `/tmp`
and saves each with `client.save_file(filepath)`. It then applies tags with
`client.add_tags_to_file(filename, tags)`, using the matching source filename
without the `/tmp/` prefix.
Each tag is a `SourceClient.FileTag` with a name and description.

The password reset guide receives both its topic tag and an onboarding tag in
the same tagging call. The files are written directly under `/tmp`, not inside
a randomly named temporary directory, to keep source filenames stable.

This example uses separate save and tag calls because `save_file(..., tags=...)`
was observed to produce an untagged file and a second, tagged file under a random
temporary path in the reported RAM runtime. This behavior may depend on the
runtime version; verify that synchronization produces only the three filenames

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.

Suggested change
The entry point in [run.py](./run.py) writes three text files under `/tmp`
and saves each with `client.save_file(filepath)`. It then applies tags with
`client.add_tags_to_file(filename, tags)`, using the matching source filename
without the `/tmp/` prefix.
Each tag is a `SourceClient.FileTag` with a name and description.
The password reset guide receives both its topic tag and an onboarding tag in
the same tagging call. The files are written directly under `/tmp`, not inside
a randomly named temporary directory, to keep source filenames stable.
This example uses separate save and tag calls because `save_file(..., tags=...)`
was observed to produce an untagged file and a second, tagged file under a random
temporary path in the reported RAM runtime. This behavior may depend on the
runtime version; verify that synchronization produces only the three filenames
The entry point in [run.py](./run.py) writes three text files under `/tmp`
and saves each with `client.save_file(filepath)`. It then applies tags with
`client.add_tags_to_file(filename, tags)`, using the matching source filename.
Each tag is a `SourceClient.FileTag` with a name and description.

Comment on lines +31 to +34
The example does not clear the source or delete unrelated files. It uses fixed
filenames and tag names rather than generating new names for each synchronization.
If earlier versions created entries such as `tmp.../password_reset.txt`, remove
those obsolete entries manually; this example does not clean them up.

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.

Suggested change
The example does not clear the source or delete unrelated files. It uses fixed
filenames and tag names rather than generating new names for each synchronization.
If earlier versions created entries such as `tmp.../password_reset.txt`, remove
those obsolete entries manually; this example does not clean them up.

File tags label whole documents. They are separate from the record-level
metadata filters demonstrated by the
[metadata filtering agent](../../agents/metadata_filtering_agent/).
This source demonstrates applying tags, not configuring agent retrieval filters.

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.

Suggested change
This source demonstrates applying tags, not configuring agent retrieval filters.

Comment on lines +41 to +45
## Agentic Retrieval vs Template-Based Filtering

Agentic Retrieval is often the easiest option when users interact directly with an agent and are unlikely to know the underlying metadata schema.

A template-based approach may be a better fit when retrieval filters must be explicitly controlled, generated by another application, or applied consistently across repeated queries.

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.

Suggested change
## Agentic Retrieval vs Template-Based Filtering
Agentic Retrieval is often the easiest option when users interact directly with an agent and are unlikely to know the underlying metadata schema.
A template-based approach may be a better fit when retrieval filters must be explicitly controlled, generated by another application, or applied consistently across repeated queries.

This branch has not been deployed

No deployments
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.

2 participants