Skip to content

Conversation

@1137842853
Copy link

No description provided.

伴柯 and others added 30 commits November 18, 2025 15:22
## Description
[Describe what this PR does and why]

Update interface for agent app

```python
agent_app = AgentApp(
        agent_name="Friday",
        agent_description="A helpful assistant",
    )

    @agent_app.init
    async def init_func(self):
        self.state_service = InMemoryStateService()
        self.session_service = InMemorySessionHistoryService()

        await self.state_service.start()
        await self.session_service.start()

    @agent_app.shutdown
    async def shutdown_func(self):
        await self.state_service.stop()
        await self.session_service.stop()

    @agent_app.query(framework="agentscope")
    async def query_func(
        self,
        msgs,
        request: AgentRequest = None,
    ):
        session_id = request.session_id
        user_id = request.user_id

        state = await self.state_service.export_state(
            session_id=session_id,
            user_id=user_id,
        )

        toolkit = Toolkit()
        toolkit.register_tool_function(execute_python_code)

        agent = ReActAgent(
            name="Friday",
            model=DashScopeChatModel(
                "qwen-turbo",
                api_key=os.getenv("DASHSCOPE_API_KEY"),
                enable_thinking=True,
                stream=True,
            ),
            sys_prompt="You're a helpful assistant named Friday.",
            toolkit=toolkit,
            memory=AgentScopeSessionHistoryMemory(
                service=self.session_service,
                session_id=session_id,
                user_id=user_id,
            ),
            formatter=DashScopeChatFormatter(),
        )

        if state:
            agent.load_state_dict(state)

        async for msg, last in stream_printing_messages(
            agents=[agent],
            coroutine_task=agent(msgs),
        ):
            yield msg, last

        state = agent.state_dict()

        await self.state_service.save_state(
            user_id=user_id,
            session_id=session_id,
            state=state,
        )

    agent_app.run(host="127.0.0.1", port=PORT)
```

## Type of Change
- [ ] Bug fix
- [ ] New feature
- [x] Breaking change
- [ ] Documentation
- [ ] Refactoring

## Component(s) Affected
- [x] Engine
- [ ] Sandbox
- [ ] Documentation
- [ ] Tests
- [ ] CI/CD

## Checklist
- [ ] Pre-commit hooks pass
- [ ] Tests pass locally
- [ ] Documentation updated (if needed)
- [ ] Ready for review

## Testing
```bash
pytest tests/integrated/test_agent_app.py -s \
  --log-cli-level=DEBUG
```

## Additional Notes
[Optional: any other context]
…iguration, components, and basic structure (agentscope-ai#206)

Co-authored-by: 笙磬 <[email protected]>
# Conflicts:
#	.github/workflows/unit_test.yml
#	src/agentscope_runtime/engine/services/sandbox/sandbox_service.py
# Conflicts:
#	.github/workflows/unit_test.yml
#	pyproject.toml
# Conflicts:
#	cookbook/_toc.yml
#	pyproject.toml
#	src/agentscope_runtime/engine/services/sandbox/sandbox_service.py
@1137842853 1137842853 requested a review from a team December 25, 2025 03:36
@cla-assistant
Copy link

cla-assistant bot commented Dec 25, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
3 out of 6 committers have signed the CLA.

✅ rayrayraykk
✅ lishengzxc
✅ pitt-liang
❌ 伴柯
❌ iSample
❌ jinliyl


伴柯 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

7 participants