Manage agent conversational sessions and cursors#2259
Conversation
Co-authored-by: kelvin.sundli <kelvin.sundli@cognite.com>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: kelvin.sundli <kelvin.sundli@cognite.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2259 +/- ##
==========================================
+ Coverage 90.84% 90.85% +0.01%
==========================================
Files 167 167
Lines 24785 24865 +80
==========================================
+ Hits 22516 22592 +76
- Misses 2269 2273 +4
🚀 New features to boost your workflow:
|
Co-authored-by: kelvin.sundli <kelvin.sundli@cognite.com>
|
@cursor Hey! I still see some issues in the linting and static code checks: Run pre-commit run --all-files --show-diff-on-failure
Found 6 errors (6 fixed, 0 remaining). ruff format..............................................................Failed
3 files reformatted, 358 files left unchanged debug statements (python)................................................Passed
diff --git a/cognite/client/data_classes/agents/chat.py b/cognite/client/data_classes/agents/chat.py from abc import ABC, abstractmethod from cognite.client.data_classes._base import CogniteObject, CogniteResource, CogniteResourceList
diff --git a/tests/tests_unit/test_api/test_agents_session.py b/tests/tests_unit/test_api/test_agents_session.py
@@ -93,13 +91,8 @@ class TestAgentSession:
@@ -146,11 +136,7 @@ class TestAgentStartSession:
@@ -162,10 +148,7 @@ class TestAgentStartSession:
@@ -176,10 +159,7 @@ class TestAgentStartSession:
@@ -187,10 +167,7 @@ class TestAgentStartSession:
@@ -199,10 +176,7 @@ class TestAgentStartSession: class TestIntegrationWorkflow:
\ No newline at end of file
Error: Process completed with exit code 1. |
…redundancy Co-authored-by: kelvin.sundli <kelvin.sundli@cognite.com>
Description
This PR introduces a higher-level abstraction for interacting with Cognite Agents, simplifying multi-turn conversations by automatically managing the chat cursor.
A new
AgentSessionclass is added, which encapsulates the state of a conversation, including theagent_idand the currentcursor. This allows users to initiate a session and then callsession.chat()repeatedly without manually extracting and passing the cursor from previous responses.The
AgentSessioncan be started in two ways:client.agents.start_session(agent_id: str, cursor: str | None = None).Agentinstance:agent.start_session(cursor: str | None = None).This change significantly improves the developer experience for building conversational applications with Cognite Agents.
Checklist:
If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.