Skip to content

refactor: enforce act/aact without strategy - #1468

Open
AngeloDanducci wants to merge 3 commits into
generative-computing:mainfrom
AngeloDanducci:ad-1448
Open

refactor: enforce act/aact without strategy#1468
AngeloDanducci wants to merge 3 commits into
generative-computing:mainfrom
AngeloDanducci:ad-1448

Conversation

@AngeloDanducci

Copy link
Copy Markdown
Contributor

Pull Request

Issue

Fixes #1448

Description

Code now has two requirements set apart:

  1. Requirements the action renders into its prompt - e.g. those attached to an Instruction or a generative stub. These still shape the output even with no strategy, so they're fine. -> exempt, no error.
  2. Requirements only a strategy could check - passed via the requirements= kwarg but not attached to the action. With strategy=None these do literally nothing. -> now raises ValueError.

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code was added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Attribution

  • AI coding assistants used

Adding a new component, requirement, sampling strategy, or tool?

If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.

  • Component
  • Requirement
  • Sampling Strategy
  • Tool

NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.

Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
@github-actions github-actions Bot added the enhancement New feature or request label Jul 29, 2026
@AngeloDanducci
AngeloDanducci marked this pull request as ready for review July 29, 2026 18:38
@AngeloDanducci
AngeloDanducci requested a review from a team as a code owner July 29, 2026 18:38

@markstur markstur 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.

Before "Approve", I want to ask what "first pass at" implies. Is this ready and that's just the right way to describe continuous improvement or does it indicate work-in-progress? It sounds unfinished, but it looks good.

I found 2 nits which you may choose to ignore:

1 - see inline: I commented where you might use join() instead of list repr, but I already decided that I like your way for simple/effective.
2 - I think the very verbose exception message repeated in a comment and in a docstring is a bit much. I would try to shorten or eliminate the comment if the code is more readable w/o it (the message is near enough) -- but that's something I only recommend you do if you are in the code anyway and "see it" the way I did. Not blocking approval.

Comment thread mellea/stdlib/functional.py Outdated
raise ValueError(
"Requirements were provided without a SamplingStrategy and "
"are not rendered by the action, so they cannot be validated: "
f"{[r.description for r in unvalidated]}. Pass a `strategy` "

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.

I was going to suggest a join() here to make a nicer natural language message, but using a list like this gets readability with less worry about quotes and separators. I'd keep as-is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shortened one of the verbose comments.

Re first pass - a (bad?) habit of mine that on a first commit to a new branch.
In the spirit of continuous improvement - this commit should cover everything as is.

@AngeloDanducci AngeloDanducci changed the title refactor: first pass at enforcing act aact without strategy refactor: enforce act/aact without strategy Jul 30, 2026
Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
@AngeloDanducci
AngeloDanducci requested a review from markstur July 30, 2026 18:51

@jakelorocco jakelorocco 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.

one small question; thanks for updating the docstrings as well, makes things much more clear

Comment thread mellea/stdlib/functional.py Outdated
Comment on lines +705 to +707
if requirements:
rendered = _requirements_rendered_by_action(action)
unvalidated = [r for r in requirements if id(r) not in rendered]

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.

Can you please elaborate on why this is needed? Can we modify ainstruct to just not pass the requirements if no sampling strategy is provided (or whatever makes sense in that case)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ainstruct yes (and maybe that is sufficient).

Calling aact(action, requirements=[loose_req], strategy=None) directly would still silently drop loose_req with no signal though IIUC.

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.

Okay, then I would advocate for:

  1. doing any necessary rendered / unrendered requirement parsing in ainstruct (which I don't think will require a function like this since all the data is there from parameters)
  2. just raise an exception if a requirement is passed directly into aact without a strategy (we can even investigate changing the overloads to make this more clear)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed - I agree I think this is cleaner.

Signed-off-by: AngeloDanducci <angelo.danducci.ii@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce or clearly signal requirements-without-strategy in act()/aact()

3 participants