Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: Enable plan validation in the SequentialPlanner #2855

Closed
lnavarette opened this issue Sep 18, 2023 · 6 comments
Closed

Java: Enable plan validation in the SequentialPlanner #2855

lnavarette opened this issue Sep 18, 2023 · 6 comments
Labels
java Issue or PR regarding Java code planner Anything related to planner or plans stale Issue is stale because it has been open for 90 days with no activity

Comments

@lnavarette
Copy link
Contributor

We've been using the experimental java branch with the SequentialPlanner. Sometimes, the LLM will return a plan that uses some example skills we don't implement in our project.

For example, the plan might look like

Steps:
  - CustomSkill.MyCustomSemanticFunction ...
  - Emailer.EmailTo ...

where we have implemented CustomSkill.MyCustomSemanticFunction but not Emailer.EmailTo

It happens infrequently (we have the temperature set to 0 and see it <5% of the time in our tests), so I tried to implement logic in our project to inspect the resulting Plan to check if any of the steps weren't available to the kernel, but the steps on the plan are not accessible.

I assume this will be a common problem; I could see a few different ways to approach it:

  • Make the steps accessible (even a read-only list or copied list) so that the consumer can do the validation
  • Add some validation method on the Plan itself for a user to check if it's executable and retry creation if it is not
  • Perform some validate plan and/or retry creation as part of the plan creation to reduce the likelihood of consumers getting back a plan that can't be executed.
@shawncal shawncal added java Issue or PR regarding Java code triage labels Sep 18, 2023
@github-actions github-actions bot changed the title Enable plan validation in the SequentialPlanner Java: Enable plan validation in the SequentialPlanner Sep 18, 2023
@evchaki evchaki added planner Anything related to planner or plans and removed triage labels Oct 2, 2023
@evchaki evchaki moved this to Backlog - Planner in Java Semantic Kernel Oct 2, 2023
@evchaki
Copy link
Contributor

evchaki commented Oct 2, 2023

@johnoliver - we have this feature in .net, can you take a look and see if we have this in Java to stop making up plugins that are not there. - @alliscode can provide more details here also.

@johnoliver
Copy link
Member

We will take a look at implementing this our side, @alliscode is this the correct code to be looking at:

https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/Planners/Planners.Core/Sequential/SequentialPlanParser.cs#L171

@lnavarette
Copy link
Contributor Author

Is this something you'd be open to contributions on if it becomes a high priority for us before it becomes a high priority for you?

@johnoliver
Copy link
Member

@lnavarette Yes we are absolutely open to contributions, feel free to message in the discord if you want to discuss it, I believe the validation model c# side is at: https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/Planners/Planners.Core/Sequential/SequentialPlanParser.cs#L171 so can replicate that, and if there is any other validation you think we can do let us know.

github-merge-queue bot pushed a commit that referenced this issue Nov 8, 2023
…er (#3384)

### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

This is to resolve #2855 -- when using the java `SequentialPlanner`, the
planner will return a plan with missing skills. This enables a
configuration setting to allow/disallow the missing functions.

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

This PR adds
* The configuration setting to allow/disallow missing functions. I set
the default to false (throw on a missing function), technically a
breaking change from what was previously implemented. Given this branch
is still prerelease, I decided that's the better default configuration,
and the breaking change should be okay.
* The logic in the plan parser; to throw when
`allowMissingFunctions=true` and the plan has a missing function.
* Unit tests for the SequentialPlanner that bring its tests to parity
with the other Planner unit tests and test the desired behavior for this
setting when it is on or off.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄

---------

Co-authored-by: Linda Navarette <[email protected]>
Copy link

This issue is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale Issue is stale because it has been open for 90 days with no activity label Mar 27, 2024
@d3r3kk
Copy link
Contributor

d3r3kk commented Apr 16, 2024

Closing as we are not planning on implementing planners right now. Instead we will be implementing tool calling for the V1 release line.

@d3r3kk d3r3kk closed this as completed Apr 16, 2024
@github-project-automation github-project-automation bot moved this to Sprint: Done in Semantic Kernel Apr 16, 2024
johnoliver pushed a commit to johnoliver/semantic-kernel that referenced this issue Jun 5, 2024
…er (microsoft#3384)

### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

This is to resolve microsoft#2855 -- when using the java `SequentialPlanner`, the
planner will return a plan with missing skills. This enables a
configuration setting to allow/disallow the missing functions.

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

This PR adds
* The configuration setting to allow/disallow missing functions. I set
the default to false (throw on a missing function), technically a
breaking change from what was previously implemented. Given this branch
is still prerelease, I decided that's the better default configuration,
and the breaking change should be okay.
* The logic in the plan parser; to throw when
`allowMissingFunctions=true` and the plan has a missing function.
* Unit tests for the SequentialPlanner that bring its tests to parity
with the other Planner unit tests and test the desired behavior for this
setting when it is on or off.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄

---------

Co-authored-by: Linda Navarette <[email protected]>
johnoliver pushed a commit to johnoliver/semantic-kernel that referenced this issue Jun 5, 2024
…er (microsoft#3384)

### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

This is to resolve microsoft#2855 -- when using the java `SequentialPlanner`, the
planner will return a plan with missing skills. This enables a
configuration setting to allow/disallow the missing functions.

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

This PR adds
* The configuration setting to allow/disallow missing functions. I set
the default to false (throw on a missing function), technically a
breaking change from what was previously implemented. Given this branch
is still prerelease, I decided that's the better default configuration,
and the breaking change should be okay.
* The logic in the plan parser; to throw when
`allowMissingFunctions=true` and the plan has a missing function.
* Unit tests for the SequentialPlanner that bring its tests to parity
with the other Planner unit tests and test the desired behavior for this
setting when it is on or off.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [ ] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄

---------

Co-authored-by: Linda Navarette <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java Issue or PR regarding Java code planner Anything related to planner or plans stale Issue is stale because it has been open for 90 days with no activity
Projects
Archived in project
Development

No branches or pull requests

5 participants