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

Adding a ruleset to an Agent shouldn't also add it to the Agent's Task. #1465

Open
1 task done
shhlife opened this issue Dec 19, 2024 · 2 comments
Open
1 task done
Labels
type:bug Something isn't working
Milestone

Comments

@shhlife
Copy link

shhlife commented Dec 19, 2024

Describe the bug
If you instantiate an agent and give it a ruleset, it automatically adds that ruleset to both the Agent and it's associated task:

default_ruleset = Ruleset(name="Default_Ruleset", rules=[Rule("You are happy!")])

# Create the agent
agent_A = Agent(rulesets=[default_ruleset], stream=True)

If you look at the dict created, you'll see the ruleset is on both the Agent, and also on the PromptTask:

{
    'type': 'Agent',
    'rulesets': [
        {
            'type': 'Ruleset',
            'id': '07f917db5bce4c1e89fe31a880ff9657',
            'name': 'Default_Ruleset',
            'meta': {},
            'rules': [{'type': 'Rule', 'value': 'You are happy!'}]
        }
    ],
    'id': '45d755a81fe649118cb0729540f20db6',
    'tasks': [
        {
            'type': 'PromptTask',
            'id': 'e14c79209b124c029fad3e0114a458e7',
            'state': 'State.FINISHED',
            'parent_ids': [],
            'child_ids': [],
            'max_meta_memory_entries': 20,
            'context': {},
            'rulesets': [
                {
                    'type': 'Ruleset',
                    'id': '07f917db5bce4c1e89fe31a880ff9657',
                    'name': 'Default_Ruleset',
                    'meta': {},
                    'rules': [{'type': 'Rule', 'value': 'You are happy!'}]
                }
            ],

If you then create a PromptTask with a different ruleset and add it to the agent:

agent_A = Agent(rulesets=[default_ruleset], stream=True)
agent_A.add_task(PromptTask(rules=[Rule("You are sad!")]))

the PromptTask will have two rulesets.. the original and the new ruleset.

'tasks': [
        {
            'type': 'PromptTask',
            'id': '220f2e8b3865419aba4d0ae0c2e07bf4',
            'state': 'State.FINISHED',
            'parent_ids': [],
            'child_ids': [],
            'max_meta_memory_entries': 20,
            'context': {},
            'rulesets': [
                {
                    'type': 'Ruleset',
                    'id': '430e437c5cc34c4ea86f8ab221286fcc',
                    'name': 'Default Ruleset',
                    'meta': {},
                    'rules': [{'type': 'Rule', 'value': 'You are happy!'}]
                },
                {
                    'type': 'Ruleset',
                    'id': '1cd4a539fad04ce8bec584ad5000e196',
                    'name': 'Default Ruleset',
                    'meta': {},
                    'rules': [{'type': 'Rule', 'value': 'You are sad!'}]
                }
            ],

The agent will also still have the original ruleset..

which results in 3 rulesets.

My assumption is that Rulesets would only exist on the entity you give it, otherwise it's a bit confusing as to where they end up, and you end up needing to manipulate them in multiple places if you want to make changes.

@shhlife shhlife added the type:bug Something isn't working label Dec 19, 2024
@collindutter
Copy link
Member

This is an unfortunate side effect of how Rules are inherited from Structures. I've actually been thinking about removing the ability to set Rules on Structures; I feel that it only adds confusion and does not provide much real world value.

What do you think about that change?

@collindutter collindutter added this to the 2.0 milestone Dec 19, 2024
@shhlife
Copy link
Author

shhlife commented Dec 19, 2024

Yeah, I think that would confuse me - I like having structures with rules that are overarching, and then specific rules per-task.

Mixing and matching can be helpful, especially if you've got task/swapping going on. So IMHO I'd love to not get rid of structure rulesets, and also keep task rulesets. When instantiating the agent, if the ruleset is on it, then just put it on the agent. If it's on the task, then put it on the task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants